MapleSelectIndexed - Maple Programming Help

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

MapleSelectIndexed

select from a table, list, or rtable in external code

MapleSelectImaginaryPart

select the imaginary part of a complex-valued expression in external code

MapleSelectRealPart

select the real part of a complex-valued expression in external code

 Calling Sequence MapleSelectIndexed(kv, s, n, ind) MapleSelectImaginaryPart(kv, s) MapleSelectRealPart(kv, s)

Parameters

 kv - kernel handle of type MKernelVector s - type ALGEB indexable object n - length of ind ind - index array

Description

 • These functions can be used in external code with OpenMaple or define_external.
 • MapleSelectIndexed retrieves the element s[ind], where s is a list, set, table, or rtable object. The index is an integer array.  To reference s[1,2], set ind[0] = 1, and ind[1] = 2;.
 • MapleSelectImaginaryPart returns the imaginary part of s. MapleSelectRealPart returns the real part of s. These commands are equivalent to the Maple Im and Re commands.

Examples

 #include "maplec.h" ALGEB M_DECL MyRe( MKernelVector kv, ALGEB *args ) { ALGEB list, val; char *code; M_INT i, n, index[1]; if( MapleNumArgs(kv,(ALGEB)args) != 2 ) { MapleRaiseError(kv,"two arguments expected"); return( NULL ); } n = MapleToM_INT(kv,args[1]); list = MapleListAlloc(kv,n); for( i=1; i<=n; ++i ) { index[0] = i; val = MapleSelectIndexed(kv,args[2],1,index); MapleListAssign(kv,list,i,MapleSelectRealPart(kv,val)); } return( list ); }

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{re}≔\mathrm{DefineExternal}\left("MyRe",\mathrm{dll}\right):$
 > $\mathrm{re}\left(3,\left[1-I,2-2I,3-3I\right]\right)$
 $\left[{1}{,}{2}{,}{3}\right]$ (1)
 > $\mathrm{re}\left(3,\left\{1-I,2-2I,3-3I\right\}\right)$
 $\left[{1}{,}{2}{,}{3}\right]$ (2)
 > $\mathrm{re}\left(3,⟨1-I,2-2I,3-3I⟩\right)$
 $\left[{1}{,}{2}{,}{3}\right]$ (3)
 > $\mathrm{re}\left(3,\mathrm{table}\left(\left[1=1-I,2=2-2I,3=3-3I\right]\right)\right)$
 $\left[{1}{,}{2}{,}{3}\right]$ (4)