<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>callMaple -- Run a Maple program from Macaulay 2.</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_read__Maple.html">next</a> | <a href="index.html">previous</a> | <a href="_read__Maple.html">forward</a> | <a href="index.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>callMaple -- Run a Maple program from Macaulay 2.</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>callMaple(mapleprogram)</tt><br/><tt>callMaple(inputdata1,inputdata2,mapleprogram)</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>inputdata1</tt>, <span>a <a href="../../Macaulay2Doc/html/___String.html">string</a></span></span></li> <li><span><tt>inputdata2</tt>, <span>a <a href="../../Macaulay2Doc/html/___String.html">string</a></span></span></li> <li><span><tt>mapleprogram</tt>, <span>a <a href="../../Macaulay2Doc/html/___String.html">string</a></span></span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><span>a <a href="../../Macaulay2Doc/html/___Thing.html">thing</a></span></span></li> </ul> </div> </li> <li><div class="single"><a href="../../Macaulay2Doc/html/_using_spfunctions_spwith_spoptional_spinputs.html">Optional inputs</a>:<ul><li><span><a href="_store.html">store => ...</a>, -- Store result of a Maple computation in a file.</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><p>This function calls a Mapleprogram given as a string mapleprogram.</p> <p>Note that any command line there has to end with a semicolon.</p> <p>The arguments inputdata1 and inputdata2 are here just for convenience and you can put the empty strings if you want or leave them away.</p> <p>Inside mapleprogram the string placeholder1 is then replaced by the string inputdata1 and placeholder2 is replaced the string inputdata2.</p> <p>In the string inputdata1 we take care automatically of the main compatibility problem between <i>Macaulay2</i> and Maple which is replacing in lists the curly brackets are by square brackets.</p> <p>The Maple program has to write its output in the Maple variable returnvalue. This is converted in Maple into a string, square brackets are replaced by curly brackets and then this string is evaluated in <i>Macaulay2</i> via the function <a href="../../Macaulay2Doc/html/_value.html" title="evaluate">value</a>.</p> <p>A very simple example:</p> <div/> <table class="examples"><tr><td><pre>i1 : L={3,5} o1 = {3, 5} o1 : List</pre> </td></tr> <tr><td><pre>i2 : mapleprogram="L:=placeholder1;returnvalue:=L[1]+L[2];";</pre> </td></tr> <tr><td><pre>i3 : callMaple(toString L,"",mapleprogram) o3 = 8</pre> </td></tr> </table> <p></p> <p>Here is an example how to send a <a href="../../Macaulay2Doc/html/___Matrix.html" title="the class of all matrices">Matrix</a> to Maple, compute its integer normal form and send it back to <i>Macaulay2</i>:</p> <div/> <table class="examples"><tr><td><pre>i4 : A=matrix {{1,5,7},{7,13,5}} o4 = | 1 5 7 | | 7 13 5 | 2 3 o4 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i5 : inputdata1=toString entries A o5 = {{1, 5, 7}, {7, 13, 5}}</pre> </td></tr> <tr><td><pre>i6 : mapleprogram="with(linalg,ismith);A:=placeholder1;S:=ismith(A);returnvalue:=convert(S,listlist);";</pre> </td></tr> <tr><td><pre>i7 : matrix callMaple(inputdata1,"",mapleprogram) o7 = | 1 0 0 | | 0 22 0 | 2 3 o7 : Matrix ZZ <--- ZZ</pre> </td></tr> </table> <p></p> <p>Using inputdata2 to pass the command ismith to Maple:</p> <div/> <table class="examples"><tr><td><pre>i8 : A=matrix {{1,5,7},{7,13,5}} o8 = | 1 5 7 | | 7 13 5 | 2 3 o8 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i9 : inputdata1=toString entries A o9 = {{1, 5, 7}, {7, 13, 5}}</pre> </td></tr> <tr><td><pre>i10 : inputdata2="ismith" o10 = ismith</pre> </td></tr> <tr><td><pre>i11 : mapleprogram="with(linalg,placeholder2);A:=placeholder1;S:=placeholder2(A);returnvalue:=convert(S,listlist);";</pre> </td></tr> <tr><td><pre>i12 : matrix callMaple(inputdata1,inputdata2,mapleprogram) o12 = | 1 0 0 | | 0 22 0 | 2 3 o12 : Matrix ZZ <--- ZZ</pre> </td></tr> </table> <p></p> <p>(Note that it may be more convenient for you to use for mapleprogram the three-slashes string delimiter but this cannot be done here in the doc environment).</p> <p>Same program but obtaining also the base change matrices:</p> <div/> <table class="examples"><tr><td><pre>i13 : A=matrix {{1,5,7},{7,13,5}} o13 = | 1 5 7 | | 7 13 5 | 2 3 o13 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i14 : inputdata1=toString entries A o14 = {{1, 5, 7}, {7, 13, 5}}</pre> </td></tr> <tr><td><pre>i15 : inputdata2="ismith";</pre> </td></tr> <tr><td><pre>i16 : mapleprogram="with(linalg,placeholder2):A:=placeholder1;S:=placeholder2(A,U,V);returnvalue:=[convert(S,listlist),convert(U,listlist),convert(V,listlist)];";</pre> </td></tr> <tr><td><pre>i17 : L=callMaple(inputdata1,inputdata2,mapleprogram);</pre> </td></tr> <tr><td><pre>i18 : S=matrix L#0 o18 = | 1 0 0 | | 0 22 0 | 2 3 o18 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i19 : U=matrix L#1 o19 = | 1 0 | | -7 1 | 2 2 o19 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i20 : V=matrix L#2 o20 = | 1 5 3 | | 0 -1 -2 | | 0 0 1 | 3 3 o20 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i21 : U*A*V==S o21 = true</pre> </td></tr> </table> </div> </div> <div class="waystouse"><h2>Ways to use <tt>callMaple</tt> :</h2> <ul><li>callMaple(String)</li> <li>callMaple(String,String,String)</li> </ul> </div> </div> </body> </html>