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
Parameters
Description
Examples
RTableLowerBound(kv, rt, dim)
RTableUpperBound(kv, rt, dim)
kv
-
kernel handle of type MKernelVector
rt
type ALGEB rtable object
dim
integer specifying dimension
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]).
#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");
rt1 = args[1];
RTableGetSettings(kv,&rts,rt1);
if( rts.data_type != RTABLE_DAG ) {
MapleRaiseError(kv,"DAG rtable expected for parameter 1");
if( rts.storage == RTABLE_SPARSE ) {
MapleRaiseError(kv,"dense rtable expected for parameter 1");
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<n; ++i ) {
data2[i] = data1[i];
return( rt2 );
Execute the external function from Maple.
with⁡ExternalCalling:
dll≔ExternalLibraryName⁡HelpExamples:
reindex≔DefineExternal⁡MyReindexRTable,dll:
A≔Array⁡32..34,111..113,i,j↦3⋅i−3+j
B≔reindex⁡A
B≔204205206207208209210211212
A32,111
204
B1,1
See Also
CustomWrapper
define_external
OpenMaple
OpenMaple/C/API
OpenMaple/C/Examples
rtable
rtable_dims
Download Help Document