RTableNumDimensions - query the number of dimensions of an rtable in external code
|
Calling Sequence
|
|
RTableNumDimensions(kv, rt)
|
|
Parameters
|
|
kv
|
-
|
kernel handle of type MKernelVector
|
rt
|
-
|
type ALGEB rtable object
|
|
|
|
|
Description
|
|
•
|
RTableNumDimensions returns the number of dimensions of the given rtable, rt. This command is equivalent to calling rtable_num_dims.
|
|
|
Examples
|
|
#include "maplec.h"
|
ALGEB M_DECL MyFlattenRTable( MKernelVector kv, ALGEB *args )
|
{
|
M_INT argc, n, i, num_dims, bounds[2];
|
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 );
|
}
|
num_dims = RTableNumDimensions(kv,rt1);
|
if( num_dims <= 1 )
|
return( rt1 );
|
n = RTableNumElements(kv,rt1);
|
RTableGetDefaults(kv,&rts);
|
rts.num_dimensions = 1;
|
rts.subtype = RTABLE_ARRAY;
|
rts.data_type = RTABLE_DAG;
|
bounds[0] = 1;
|
bounds[1] = n;
|
rt2 = RTableCreate(kv,&rts,NULL,bounds);
|
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) |
|
|