Matrix form



"Ben Blomberg" <bblomberg1 at niu.edu> writes:

> Greetings everyone,
>
>
> I am new to Maxima and trying to convert a do loop from Mathematica. I
> am trying to find a function similar to MatrixForm[%] in
> mathematica. MatrixForm turns an array into a matrix and the % uses
> the results from the previous line. I have been creating a list of
> lists and trying to assign it to a matrix using aa1:matrix (aa1 is the
> name of the matrix) but the result is not what I expect.

Something like this?

  (%i1) [[1, 2], [3, 4]];
  (%o1)                          [[1, 2], [3, 4]]
  (%i2) apply(matrix, %);
                                     [ 1  2 ]
  (%o2)                              [      ]
                                     [ 3  4 ]

The trick is that matrix is a function that takes rows as (a variable
number of) arguments, so we need to convert

  [[1, 2], [3, 4]]

to

  matrix([1, 2], [3, 4])

Fortunately, that's exactly what apply does!

Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130204/071413f7/attachment-0001.pgp>;