WeBWorK Problems

Matrix functions in mathObjects

Matrix functions in mathObjects

by Danny Glin -
Number of replies: 1
Hi,
I'm in the process of coding some matrix problems using mathObjects. I was wondering if the system can do some basic matrix operations, namely determinant and inverse. I was hoping for something like the following to work:
$A=Matrix([[1,2],[3,4]]);
$Ainv=$A->inverse;
$det=$A->determinant;

Do such functions exist, and possibly just have different names?
Any help would be appreciated
In reply to Danny Glin

Re: Matrix functions in mathObjects

by Michael Gage -
Hi Danny,

There is an older module called Matrix.pm (which in turn calls a super class MatrixReal1.pm -- which I obtained from CPAN)
which can do all of these things as long you use matrices with real or complex coefficients (no formulas).

At the moment this Matrix.pm module and the MathObjects version of matrices (in Value::Matrix.pm) aren't compatible so you can only use one
or the other -- if you load MathObjects.pl it will be difficult, perhaps impossible, to refer to the matrices from MatrixReal1.pm which can do fancier
calculations. There is a little documentation at http://webwork.maa.org/doc/cvs/pg_CURRENT/lib/Matrix.html and
http://webwork.maa.org/doc/cvs/pg_CURRENT/lib/MatrixReal1.html but ultimately you'll need to look at the code if you run into anything puzzling.

We hope to combine the capabilities of the two versions of Matrix but I don't know if either Davide or I will have time to work on it this summer to create a consistent and transparent interface. MathObject matrices will do matrix multiplication and operations with scalars but that is about it. The earlier version will do LR decomposition and from that can calculate determinants and inverses.

Also note that MathObjects Formulas with matrices are formulas whose values are real or complex matrices. They are not matrices which contain formulas as entries.

Hope this helps.

---- Update 1/2012 -- the MatrixObjects can now do all or nearly all of the calculations which were available under the MatrixReal1 objects.  Documentation is coming -- Davide Cervone is working on the project this semester -- so if things are missing let us know on the forum.  

The pointers above now reside in the POD area of the wiki:  http://webwork.maa.org/pod/pg_TRUNK/