------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 199x by International Computer Science Institute            --
-- This file is part of the GNU Sather package. It is free software; you may --
-- redistribute  and/or modify it under the terms of the  GNU General Public --
-- License (GPL)  as  published  by the  Free  Software  Foundation;  either --
-- version 2 of the license, or (at your option) any later version.          --
-- This  program  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/GPL for more details.        --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- mat.sa
-- implements VERY naive matrix multiplication
-- by Claudio Fleiner

class MYMAT{T} is
   include ARRAY2{T};
end;

class MAIN is
   mult(r:MYMAT{FLT},m1:MYMAT{FLT},m2:MYMAT{FLT}) is
      loop
         i::=0.upto!(r.size1-1);
         loop
            j::=0.upto!(r.size2-1);
	    sum:FLT:=0.0;
	    loop
	       k::=0.upto!(m1.size2-1);
	       sum:=sum+m1[i,k]*m2[k,j];
	    end;
            r[j,i]:=sum;
         end;
      end;
   end;

   main(args: ARRAY{STR}) is
      n ::= #INT(args[1]);
      #OUT + "Doing it "+n+" times.\n";
      m:MYMAT{FLT}:=#(200,200);
      loop
	 n.times!;
	 mult(m,m,m);
      end;
	 
   end;
end;
