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
|
|
•
|
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.
>
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
|
|