11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.2 Using Compiled Code in Maple • 335CResult = MapleToFloat64(kv,MapleResult);EvalMapleStatement enables you to enter a single parsable Maplestatement and evaluate it. For example, the following call evaluates theintegral x 3 in the range x = 0..1.ALGEB MapleResult;double CResult;MapleResult = EvalMapleStatement(kv,"int(x^3,x=0..1)");CResult = mapleToFloat64(kv,MapleResult);MapleEval evaluates a Maple expression. It is especially useful fordetermining the value of an assigned name.Assignment to Maple Variables The following assignment functions areavailable only when using the C API.ALGEB MapleAssign( MKernelVector kv, ALGEB lhs, ALGEB rhs );ALGEB MapleAssignIndexed( MKernelVector kv, ALGEB lhs,M_INT dim, M_INT *ind, ALGEB rhs );MapleAssign sets the value dag rhs to the name dag lhs. This isequivalent to the Maple statement> lhs := rhs;MapleAssignIndexed sets the value rhs to the indexed variable lhs.The second parameter dim indicates the number of dimensions in thearray (or 1 if lhs is a table). The third parameter ind is a hardwarearray of indices.For example, to make the assignment a[1][2][3] = 3.14, the followingcode could be used (assuming arg1 points to the array a).ALGEB rhs;M_INT ind[3];ind[0] = 1;ind[1] = 2;ind[3] = 3;rhs = ToMapleFloat(kv,3.14);MapleAssignIndexed(kv,arg1,3,ind,rhs);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!