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
|
|
•
|
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<n; ++i ) {
|
data2[i] = data1[i];
|
}
|
return( rt2 );
|
}
|
|
|
Execute the external function from Maple.
>
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
|
|