assign a value to a Maple variable in external code - Maple Help

Online Help

All Products    Maple    MapleSim


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.

withExternalCalling:

dll:=ExternalLibraryNameHelpExamples:

mult:=DefineExternalMyMult,dll:

mult3,3

9

(1)

multπ,sinπ2

π

(2)

my_results1,my_results2

9,π

(3)

a,b

π,1

(4)

See Also

CustomWrapper, define_external, OpenMaple, OpenMaple/C/API, OpenMaple/C/Examples


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam