Matrix VS Arrays



Hi,

In addition to what Stavros said, I sometimes do things like:

mymat(m,n) := block([A],
A : zeromatrix(m,n),
for i thru m do for j thru n do A[i,j] : i+j,
A);
mymat(4,4);

hth,
Milan

* Mansur Marvanov <nanorobocop at gmail.com> [2007-12-23 17:59:10 +0300]:

> Hello!
> 
> I'm really disordered in this difference.
> 
> How can I write the matrix on function? I try this:
> 
> (%i28) func(n,m):=for i:1 thru n do for j:1 thru m do A[i,j]:i+j$
> 
> (%i29) A;
> (%o29)                                 A
> (%i30) A[1,2];
> (%o30)                                 3
> 
> But what is A? Matrix? Array?
> 
> I tried to define matrix with array's help:
> 
> (%i8) func(n,m):=(array(A,flonum,n,m),for i:1 thru n do for j:1 thru m do A[i,j]:i+j,M:genmatrix(A,n,m))$
> (%i9) func(4,4);
> 
> Element and array type do not match:
> 1234
> #0: func(n=4,m=4)
>  -- an error.  To debug this try debugmode(true);
> 
> But without success :(
> I need to define all elements of matrix in function - How can I do this?

--