Question

I am trying to find a way to convert a 41x41 array into a matrix in maxima. I tried aa1:matrix([aa]); If I try matrixp(aa1) it yields true but the matrix only contains the first value.

Does anyone have any thoughts?

Was it helpful?

Solution

IIUC Maxima arrays are hashes, so the order is not as firm as with matrices. That aside it seems it should be possible with some knowledge of how the array was generated and genmatrix, see the fifth faq entry.

So if the array is generated like this:

(%i1) for i thru 4 do for j thru 4 do A[i,j]: i+j$

We have:

(%i2) listarray(A);
(%o2)   [2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8]
(%i3) arrayinfo(A);
(%o3)   [hashed, 2, [1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]

A can be converted to a 4x4 matrix like this:

(%i4) genmatrix(A,4,4);
        [ 2  3  4  5 ]
        [            ]
        [ 3  4  5  6 ]
(%o4)   [            ]
        [ 4  5  6  7 ]
        [            ]
        [ 5  6  7  8 ]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top