|
From: Barton W. <wi...@un...> - 2014-07-08 16:36:09
|
Try this:
(%i7) M : genmatrix(A[phi],3,1);
(%o7) matrix([A[phi](1,1)],[A[phi](2,1)],[A[phi](3,1)])
Nice way to locally define function A[phi]
(%i8) M, A[phi](i,j) := cos(phi);
(%o8) matrix([cos(phi)],[cos(phi)],[cos(phi)])
In Maxima, A[phi](i,j) := cos(phi) defines a memoizing function--there are some things about memoizing functions
can be a tricky--be careful.
Alternatively, you could simply do
(%i9) M : genmatrix(lambda([i,j], cos(phi)),3,1);
(%o9) matrix([cos(phi)],[cos(phi)],[cos(phi)])
--Barton
________________________________
From: Jan Brosius <bro...@gm...>
Sent: Tuesday, July 8, 2014 11:17
To: max...@li...
Subject: [Maxima-discuss] matrix problem
Hi,
I can define
genmatrix(A[phi],3,1}
but how do I assign a value to e.g. A[phi][2,1]. See below the maxima output
(%i1) genmatrix(A[phi],3,1);
[ A (1, 1) ]
[ phi ]
[ ]
(%o1) [ A (2, 1) ]
[ phi ]
[ ]
[ A (3, 1) ]
[ phi ]
(%i2) A[phi][2,1]:=cos(phi);
define: argument cannot be an atom or a subscripted memoizing function; found:
(A )
phi
2, 1
-- an error. To debug this try: debugmode(true);
(%i3) A[phi][2,1]:cos(phi);
assignment: cannot assign to (A )
phi
2, 1
-- an error. To debug this try: debugmode(true);
thx for any help
Jan
|