RTableLowerBound - Maple Help

RTableLowerBound

query the lower bound of the ith dimension of an rtable in external code

RTableUpperBound

query the upper bound of the ith dimension of an rtable in external code

 Calling Sequence RTableLowerBound(kv, rt, dim) RTableUpperBound(kv, rt, dim)

Parameters

 kv - kernel handle of type MKernelVector rt - type ALGEB rtable object dim - integer specifying dimension

Description

 • This functions can be used in external code with OpenMaple or define_external.
 • RTableLowerBound returns the lower bound of dimension dim for the given rtable, rt.  For rtables with subtype Matrix and Vector, this always returns 1.  For Arrays, this command is equivalent to calling lhs([rtable_dims(A)][dim]), or op([2,dim,1],rt).
 • RTableUpperBound returns the upper bound of dimension dim for the given rtable, rt.  For rtables with subtype Matrix and Vector, this is equivalent to to calling op([1,dim],rt). For Arrays, this command is equivalent to calling op([2,dim,2],rt). For all rtables, it is equivalent to calling rhs([rtable_dims(A)][dim]).

Examples

 #include "maplec.h" ALGEB M_DECL MyReindexRTable( MKernelVector kv, ALGEB *args ) { M_INT argc, i, num_dims, n, bounds[RTABLE_MAX_BOUNDS]; ALGEB rt1, rt2, *data1, *data2; RTableSettings rts; argc = MapleNumArgs(kv,(ALGEB)args); if( argc != 1 ) { MapleRaiseError(kv,"one argument expected"); return( NULL ); } if( !IsMapleRTable(kv,args[1]) ) { MapleRaiseError(kv,"rtable expected for parameter 1"); return( NULL ); } rt1 = args[1]; RTableGetSettings(kv,&rts,rt1); if( rts.data_type != RTABLE_DAG ) { MapleRaiseError(kv,"DAG rtable expected for parameter 1"); return( NULL ); } if( rts.storage == RTABLE_SPARSE ) { MapleRaiseError(kv,"dense rtable expected for parameter 1"); return( NULL ); } num_dims = RTableNumDimensions(kv,rt1); for( i=1; i<=num_dims; ++i ) { bounds[2*i-2] = 1; bounds[2*i-1] = RTableUpperBound(kv,rt1,i) - RTableLowerBound(kv,rt1,i) + 1; } rt2 = RTableCreate(kv,&rts,NULL,bounds); n = RTableNumElements(kv,rt1); data1 = (ALGEB*)RTableDataBlock(kv,rt1); data2 = (ALGEB*)RTableDataBlock(kv,rt2); for( i=0; i

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{reindex}≔\mathrm{DefineExternal}\left("MyReindexRTable",\mathrm{dll}\right):$
 > $A≔\mathrm{Array}\left(32..34,111..113,\left(i,j\right)↦3\cdot i-3+j\right)$
 ${A}{≔}\begin{array}{c}\left[\begin{array}{ccc}{204}& {205}& {206}\\ {207}& {208}& {209}\\ {210}& {211}& {212}\end{array}\right]\\ \hfill {\text{32 .. 34 × 111 .. 113 Array}}\end{array}$ (1)
 > $B≔\mathrm{reindex}\left(A\right)$
 ${B}{≔}\left[\begin{array}{ccc}{204}& {205}& {206}\\ {207}& {208}& {209}\\ {210}& {211}& {212}\end{array}\right]$ (2)
 > $A\left[32,111\right]$
 ${204}$ (3)
 > $B\left[1,1\right]$
 ${204}$ (4)