RTableCreate - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

RTableCreate

create an rtable in external code

 Calling Sequence RTableCreate(kv, rts, pdata, bounds)

Parameters

 kv - kernel handle of type MKernelVector rts - pointer to an RTableSettings structure pdata - pointer to array data (optional) bounds - array of lower and upper bounds

Description

 • This function can be used in external code with OpenMaple or define_external.
 • RTableCreate creates a new rtable with the settings specified in rts.
 • If pdata is NULL, then a data block is allocated and initialized to rts->fill. When specifying a previously created block of data (that is, when pdata is not NULL), it is important that rts->foreign is set to TRUE. Size, storage, data_type, order, and indexing functions must all be considered when managing your data block. It is recommended that you let Maple create the data block, then use RTableDataBlock to create a pointer to it.
 • The array, bounds is a list of the lower and upper bounds for each dimension of the rtable.  For example, a MxN Matrix has bounds[0] = 1; bounds[1] = M; bounds[2] = 1; bounds[3] = N.
 Note: Matrix and Vector lower bounds must start at 1, not 0.

Examples

 #include "maplec.h" ALGEB M_DECL MyIdentity( MKernelVector kv, ALGEB *args ) { M_INT argc, n, i; RTableSettings rts; M_INT bounds[4]; ALGEB rt; INTEGER32 *data; argc = MapleNumArgs(kv,(ALGEB)args); if( argc != 1 ) { MapleRaiseError(kv,"one argument expected"); return( NULL ); } n = MapleToM_INT(kv,args[1]); RTableGetDefaults(kv,&rts); rts.num_dimensions = 2; rts.subtype = RTABLE_MATRIX; rts.data_type = RTABLE_INTEGER32; bounds[0] = 1; bounds[1] = n; bounds[2] = 1; bounds[3] = n; rt = RTableCreate(kv,&rts,NULL,bounds); data = (INTEGER32*)RTableDataBlock(kv,rt); for( i=1; i<=n; ++i ) { data[MATRIX_OFFSET_FORTRAN_RECT(i,i,n,n)] = 1; } return( rt ); }

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{eye}≔\mathrm{DefineExternal}\left("MyIdentity",\mathrm{dll}\right):$
 > $M≔\mathrm{eye}\left(3\right)$
 ${M}{≔}\left[\begin{array}{ccc}{1}& {0}& {0}\\ {0}& {1}& {0}\\ {0}& {0}& {1}\end{array}\right]$ (1)
 > $\mathrm{rtable_options}\left(M,\mathrm{datatype}\right)$
 ${{\mathrm{integer}}}_{{4}}$ (2)