<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi all,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Given an array <span style="font-family: "Courier New", monospace;">
@mat</span> of matrix entries, this will build the Maxima syntax for the <span style="font-family: "Courier New", monospace;">
$rows</span> x <span style="font-family: "Courier New", monospace;">$cols</span> matrix with entries
<span style="font-family: "Courier New", monospace;">@mat</span>:<span style="font-family: "Courier New", monospace;"></span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>my $maxima_mat = 'matrix(';</div>
<div>my @mat_copy = @mat;</div>
<div>for my $i (0..$rows-1) {</div>
<div>    my @row = splice(@mat_copy, 0, $cols);</div>
<div>    $maxima_mat .= '['.join(',', @row).']';</div>
<div>    if ($i != $rows-1) {$maxima_mat .= ',';}</div>
<div>}</div>
<div>$maxima_mat .= ')';</div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Then you can invert it and break it back into an array like this:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>my $inv = cas('maxima', "list_matrix_entries(invert($maxima_mat));");</div>
<div>$inv =~ s/\[|\]//g; #remove the leading and trailing []</div>
<div>my @mat_inv = split(',', $inv);</div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">I suppose it's not the prettiest, but it's certainly shorter than Perl functions for all of the matrix operations.  You could even wrap the code into Perl functions
<span style="font-family: "Courier New", monospace;">matrix_to_maxima</span> and <span style="font-family: "Courier New", monospace;">
matrix_from_maxima<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">.  You could also write similar functions if you
 are using a Perl "matrix" (<a href="https://perlmaven.com/multi-dimensional-arrays-in-perl" class="OWAAutoLink" id="LPlnk518772" previewremoved="true">https://perlmaven.com/multi-dimensional-arrays-in-perl</a>) instead of a flat array.</span><br>
<span id="ms-rterangepaste-end"></span></span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: "Courier New", monospace;"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"><br>
</span></span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: "Courier New", monospace;"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Best,</span></span></p>
<p style="margin-top:0;margin-bottom:0"><span style="font-family: "Courier New", monospace;"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Jacob</span></span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> lon-capa-users-bounces@mail.lon-capa.org <lon-capa-users-bounces@mail.lon-capa.org> on behalf of Liu, Yuk Tung <ytliu@illinois.edu><br>
<b>Sent:</b> Tuesday, February 13, 2018 12:08:23 PM<br>
<b>To:</b> Discussion list for LON-CAPA users<br>
<b>Subject:</b> [LON-CAPA-users] {Disarmed} RE: Matrix Operations</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:x_link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
span.x_EmailStyle18
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_EmailStyle19
        {font-family:"Calibri",sans-serif;
        color:#1F497D}
span.x_EmailStyle20
        {font-family:"Calibri",sans-serif;
        color:#1F497D}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
-->
</style><style type="text/css" id="owaParaStyle">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div vlink="#954F72" link="#0563C1" lang="EN-US">
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt"><br>
Hi all,<br>
<br>
Lon Capa supports both Maxima and R. They can be used to do matrix operations. I can't find examples involving matrix, but you can go to  https://loncapa.msu.edu/adm/help/Creating_Math_Response_Problems.hlp and http://www.lon-capa.org/documentation.html to
 see examples of using Maxima and R. <br>
<br>
A couple years ago, I wanted to create problems involving regressions. I used R to do that, but it only worked if the data size was not too big. So I wrote my own perl functions to perform regressions. Regressions involve matrix inversion, which I used Cholesky
 decomposition since the matrix I worked with is symmetric and positive-definite.<br>
<br>
Yuk Tung Liu<br>
E-Learning Specialist<br>
Department of Statistics<br>
University of Illinois<br>
<br>
<br>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr tabindex="-1">
<div id="x_divRpF663938" style="direction:ltr"><font size="2" face="Tahoma" color="#000000"><b>From:</b> lon-capa-users-bounces@mail.lon-capa.org [lon-capa-users-bounces@mail.lon-capa.org] on behalf of Carl Lira [lira@egr.msu.edu]<br>
<b>Sent:</b> Tuesday, February 13, 2018 8:55 AM<br>
<b>To:</b> 'Discussion list for LON-CAPA users'<br>
<b>Subject:</b> Re: [LON-CAPA-users] Matrix Operations<br>
</font><br>
</div>
<div></div>
<div>
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="color:#1F497D">Hi Gene,</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="color:#1F497D">I would take advantage of this also. I see some matrix operations available, but I don’t know if the module is installed.</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__search.cpan.org_-7Eulpfr_Math-2DMatrix-2D0.8_Matrix.pm&d=DwMFAg&c=OCIEmEwdEq_aNlsP4fF3gFqSN-E3mlr2t9JcDdfOZag&r=xsNJH7BRV_oHPnc9R-Alu7kBOiq31bgHu5mdx82zpYk&m=cZ0DC2thsyaawbW-icbHvABJUkZREthPLmF_-JF0ZzM&s=p5GS2YNIPFAqLdONRuXDul2HB4YVSlcLDsqyZRz3vDY&e=" target="_blank"><font color="red"><b>MailScanner has detected definite fraud in the website at "urldefense.proofpoint.com". Do <i>not</i> trust this website:</b></font> <font color="red"><b>MailScanner
 has detected definite fraud in the website at "urldefense.proofpoint.com". Do <i>
not</i> trust this website:</b></font> http://search.cpan.org/~ulpfr/Math-Matrix-0.8/Matrix.pm</a></span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="color:#1F497D">Carl Lira</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D">Associate Professor<br>
Department of Chemical Engineering and Materials Science<br>
2100 Engineering Building</span><span style="color:#1F497D"><br>
</span><span style="color:#1F497D">428 S. Shaw Lane</span><span style="color:#1F497D"><br>
</span><span style="color:#1F497D">Michigan State University</span><span style="color:#1F497D"><br>
</span><span style="color:#1F497D">East Lansing, MI 48824-1226</span><span style="color:#1F497D"><br>
</span><span style="color:#1F497D">Phone: (517) 355-9731</span><span style="color:#1F497D"><br>
</span><span style="color:#1F497D">FAX: (517)432-1105</span><span style="color:#1F497D"><br>
</span><span style="color:#1F497D"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.egr.msu.edu_-7Elira&d=DwMFAg&c=OCIEmEwdEq_aNlsP4fF3gFqSN-E3mlr2t9JcDdfOZag&r=xsNJH7BRV_oHPnc9R-Alu7kBOiq31bgHu5mdx82zpYk&m=cZ0DC2thsyaawbW-icbHvABJUkZREthPLmF_-JF0ZzM&s=KgidnsKWCwkMXbk-KRSFP-SdawqedYPbXqeoqnxNC70&e=" target="_blank"><font color="red"><b>MailScanner has detected definite fraud in the website at "urldefense.proofpoint.com". Do <i>not</i> trust this website:</b></font> <font color="red"><b>MailScanner
 has detected definite fraud in the website at "urldefense.proofpoint.com". Do <i>
not</i> trust this website:</b></font> <span style="color:blue">http://www.egr.msu.edu/~lira</span></a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__chethermo.net_&d=DwMFAg&c=OCIEmEwdEq_aNlsP4fF3gFqSN-E3mlr2t9JcDdfOZag&r=xsNJH7BRV_oHPnc9R-Alu7kBOiq31bgHu5mdx82zpYk&m=cZ0DC2thsyaawbW-icbHvABJUkZREthPLmF_-JF0ZzM&s=x_KHS9fqXQB-CLliVp9AUzDgDobPkHAATbQeAdqpNOQ&e=" target="_blank"><font color="red"><b>MailScanner has detected definite fraud in the website at "urldefense.proofpoint.com". Do <i>not</i> trust this website:</b></font> <font color="red"><b>MailScanner
 has detected definite fraud in the website at "urldefense.proofpoint.com". Do <i>
not</i> trust this website:</b></font> <span style="color:blue">http://chethermo.net</span></a></span><span style="color:#1F497D"></span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNormal"><a name="x__MailEndCompose"><span style="color:#1F497D"> </span></a></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b>From:</b> lon-capa-users-bounces@mail.lon-capa.org [mailto:lon-capa-users-bounces@mail.lon-capa.org]
<b>On Behalf Of </b>Harding, Gene L<br>
<b>Sent:</b> Saturday, February 10, 2018 9:56 PM<br>
<b>To:</b> Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org><br>
<b>Subject:</b> [LON-CAPA-users] Matrix Operations</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span style="color:#1F497D">Hi,</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="color:#1F497D">Does LON-CAPA have any provision for doing matrix operations (e.g., multiplication, inverse calculation or equivalent of the MATLAB “\” operator)?</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="color:#1F497D">Best regards,</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<div>
<p class="x_MsoNormal"><span style="color:black">Gene L. Harding, PE</span></p>
<p class="x_MsoNormal"><span style="color:black">Associate Professor of ECET</span></p>
<p class="x_MsoNormal"><span style="color:black">574-520-4190</span><span style="color:#1F497D"></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>