Dear Frank Rubin,

"
Except that you have to code every single case separately, 2x6, 3x10,
4x4x4, etc. You need to write a separate routine for every shape of array you
want to use."

Not so:

Use open arrays (always 0-based):

type  Matrix = array of array of TRing;

Youu can write code, roughly:

operator * (const  A, B: Matrix): Matrix;

var  RowA, ColA, RowB, ColB,
     I, J, K: Integer;
     T: TRing;

begin
RowA := Length(A); ... ColB := Length(B[0]);
if  ColA <> RowB then ...
SetLength(Result, RowA);
for  J := 0 to RowA - 1  do  SetLength(Result[J], ColB);
for  I := 0  to  RowA - 1  do
 for  K := 0  to  ColB - 1  do
  begin
  T := Zero;  // prefer just 0
  for  J := 0  to  ColA - 1  do
   T := T + A[I, J]*B[J, K];
  Result[I, K] := T;
  end;
end;

once and for all, covering all sizes of matrices.

The problem I do not yet know how to solve:
to do it for all TRing.

So I need a type TRing that can include any structure
that has + and * operators, and a 0 element:

Integers,  Floats, Rationals, Gaussian Integers,
Polynomials  with xxx coefficients,... any possible
data type I can define with overloaded +, *, etc.

Note that 0 is a problem in itself  -- one really needs
to overload it too!

Frank
Heckenbach's first reply to me may contain the answer.
I haven't completely digested it yet.

Cheers,

Harley

----------------------------------------------------

Contestcen@aol.com wrote:
For your information: that already exists  in FPC. It's called operator 
    
overloading:
  
 http://www.freepascal.org/docs-html/ref/refch12.html#x161-16800012

 -- 
Felipe Monteiro de Carvalho
    


Except that you have to code  every single case separately, 2x6, 3x10, 
4x4x4, etc.  You need to write a  separate routine for every shape of array you 
want to use.

Frank Rubin  




  

-- 
=============================
Prof. Harley Flanders
3533 Windemere Court
Ann Arbor, MI 48105-2867
Home: 734 668 1546
harley@umich.edu
=============================