MapleAssign - Maple Help

Home : Support : Online Help : Programming : OpenMaple : C Application Programming Interface : Assignment and Selection Functions : OpenMaple/C/MapleAssign

MapleAssign

assign a value to a Maple variable in external code

MapleAssignIndexed

assign to an indexable object element in external code

 Calling Sequence MapleAssign(kv, lhs, rhs) MapleAssignIndexed(kv, lhs, n, ind, rhs)

Parameters

 kv - kernel handle of type MKernelVector lhs - type ALGEB assignable object rhs - type ALGEB value n - length of ind ind - index array

Description

 • These functions can be used in external code with OpenMaple or define_external.
 • MapleAssign attempts to assign lhs := rhs.
 • MapleAssignIndexed attempts to assign lhs[ind] := rhs. The index, ind is an integer array. To reference lhs[1,2], set ind[0] = 1, and ind[1] = 2.

Examples

 #include "maplec.h" ALGEB M_DECL MyMult( MKernelVector kv, ALGEB *args ) { ALGEB a, b, r, val; static M_INT index[1] = { 1 }; if( MapleNumArgs(kv,(ALGEB)args) != 2 ) { MapleRaiseError(kv,"two arguments expected"); return( NULL ); } a = ToMapleName(kv,"a",TRUE); MapleAssign(kv,a,args[1]); b = ToMapleName(kv,"b",TRUE); MapleAssign(kv,b,args[2]); val = EvalMapleStatement(kv,"a*b;"); r = ToMapleName(kv,"my_results",TRUE); MapleAssignIndexed(kv,r,1,index,val); index[0]++; return( val ); }

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{mult}≔\mathrm{DefineExternal}\left("MyMult",\mathrm{dll}\right):$
 > $\mathrm{mult}\left(3,3\right)$
 ${9}$ (1)
 > $\mathrm{mult}\left(\mathrm{π},\mathrm{sin}\left(\frac{\mathrm{π}}{2}\right)\right)$
 ${\mathrm{π}}$ (2)
 > ${\mathrm{my_results}}_{1},{\mathrm{my_results}}_{2}$
 ${9}{,}{\mathrm{π}}$ (3)
 > $a,b$
 ${\mathrm{π}}{,}{1}$ (4)