# [LON-CAPA-users] looking for linear algebra library

Peter Riegler lon-capa-users@mail.lon-capa.org
Tue, 20 Nov 2007 13:35:22 +0100

```Hi,

basically, perl's split will do the job.
One of my students, Yuriy, is currently working on a library that
facilitates things like that. The following fragment is taken out of
that, assuming that \$maximamatrix contains maxima's return. @matrix will
contain a perl array of row vectors

#convert response from Maxima to array
my @matrix;
while (\$maximamatrix =~ s/\[([^\[\])]+)\]//) {
my \$s = \$1;
my @t = split(/,/,\$s);
push(@matrix,\@t);
}

As the said library seems to be useful, we will hurry up to publish it.
I will keep you informed.

Peter

PS (to Yuriy) : maybe a lazy quantifier
\$maximamatrix =~ s/\[(.+?)\]//
would be more efficient ...?

Jay Sullivan wrote:

> Thanks for the pointer. I think I will like using the maxima
> interface. However, I'm stuck trying to figure out how to pass a
> matrix from maxima into a perl variable.
>
> Based on the example below, from the output, it looks like maxima
> received the correct matrix input and evaluated the inverse matrix
> correctly. How could I assign the output of the &cas routine to a
> multidimensional perl array? Any tips? Thanks.
>
> code:
> <problem>
> <script type="loncapa/perl">
> \$s= 'maxima';
> @B = ();
> \$str = &cas(\$s,'invert(matrix([10,0,0],[0,3,0],[0,0,1]))');
> \$str=~s/matrix//;
> @B = \$str;
> \$tmp = \$B[0][0];
> </script>
> \$str<br/>
> \$tmp
> </problem>
>
> output:
> ([1/10,0,0],[0,1/3,0],[0,0,1])
> \$tmp
>
> JS
>
> On Nov 18, 2007 4:53 PM, Peter Riegler <p.riegler@fh-wolfenbuettel.de> wrote:
>
>>Hi,
>>
>>Maxima comes with all the functionalities you need here.
>>You might want to have a look at the ressources at
>>or
>>
>>Most of them are in German, but the source code should be available.
>>
>>Peter
>>
>>
>>Jay Sullivan wrote:
>>
>>
>>>Does anyone have a linear algebra perl library they would mind sharing?
>>>
>>>I'm looking for basic matrix functionality: matrix add, subtract,
>>>multiply, determinant, inverse
>>>
>>>Thanks,
>>>Jay
>>>_______________________________________________
>>>LON-CAPA-users mailing list
>>>LON-CAPA-users@mail.lon-capa.org
>>>http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>>
>>--
>>Peter Riegler
>>Fachhochschule Braunschweig/Wolfenbüttel
>>Salzdahlumer Str. 46/48, 38302 Wolfenbüttel
>>Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
>>email: p.riegler@fh-wolfenbuettel.de
>>http://public.rz.fh-wolfenbuettel.de/~riegler
>>_______________________________________________
>>LON-CAPA-users mailing list
>>LON-CAPA-users@mail.lon-capa.org
>>http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>>
>
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

--
Peter Riegler
Fachhochschule Braunschweig/Wolfenbüttel
Salzdahlumer Str. 46/48, 38302 Wolfenbüttel
Tel. +49 5331 939 6314, Fax. +49 5331 939 6002
email: p.riegler@fh-wolfenbuettel.de
http://public.rz.fh-wolfenbuettel.de/~riegler

```