Generating random matrices?



hi alasdair,

> f[i,j]:random(10);
> A:genmatrix(f,4,4);
> B:genmatrix(f,4,4);
>
> But A and B are exactly the same.  It seems that the random number
> generator is reset each time it is called by f[i,j] in genmatrix.

no, it's not the rng. when a function is defined with
square braces, it is a "memoizing" function.
after computing f [2, 3] once, the value is stored,
and the function isn't executed again for arguments [2, 3].
btw listarray (f); => list of stored values.

here is a subterfuge to discourage maxima from
memoizing the function values --

f: lambda ([i, j], random (10));

i think you'll find genmatrix (f, 4, 4); now yields different
results each time.

hope this helps,
robert dodier