RTableNumElements
query the number of elements in an rtable in external code
Calling Sequence
Parameters
Description
Examples
RTableNumElements(kv, rt)
kv
-
kernel handle of type MKernelVector
rt
type ALGEB rtable object
This function can be used in external code with OpenMaple or define_external.
RTableNumElements returns the number of elements in the rtable rt. This command is equivalent to calling rtable_num_elems with the Stored option.
For dense rtables, this command returns the number of elements of storage allocated. For example, a 2x2 rectangular rtable has 4 elements.
For NAG-sparse format rtables, this command returns the number of elements in the data vector specified, which is the same as the length of each index vector. Note that the number returned in this case is the number of data elements filled, not the number of elements allocated. For information and restrictions on this format, see ?sparse.
For Maple-sparse rtables, this command returns zero.
#include "maplec.h"
ALGEB M_DECL MySetAllElems( MKernelVector kv, ALGEB *args )
{
M_INT argc, n, i;
ALGEB rt;
FLOAT64 val, *data;
RTableSettings rts;
argc = MapleNumArgs(kv,(ALGEB)args);
if( argc != 2 ) {
MapleRaiseError(kv,"two argument expected");
return( NULL );
}
val = MapleToFloat64(kv,args[2]);
if( !IsMapleRTable(kv,args[1]) ) {
MapleRaiseError(kv,"rtable expected for parameter 1");
rt = args[1];
RTableGetSettings(kv,&rts,rt);
if( rts.data_type != RTABLE_FLOAT64 ) {
MapleRaiseError(kv,"float[8] rtable expected for parameter 1");
data = (FLOAT64*)RTableDataBlock(kv,rt);
n = RTableNumElements(kv,rt);
for( i=0; i<n; ++i ) {
data[i] = val;
return( rt );
Execute the external function from Maple.
with⁡ExternalCalling:
dll≔ExternalLibraryName⁡HelpExamples:
setall≔DefineExternal⁡MySetAllElems,dll:
M≔Matrix⁡2,datatype=float8:
setall⁡M,3
3.3.3.3.
M≔Matrix⁡2,shape=triangularupper,datatype=float8:
3.3.0.3.
M≔Matrix⁡2,storage=sparse2,datatype=float8:
0.0.0.0.
M1,1≔9
3.0.0.0.
See Also
CustomWrapper
define_external
OpenMaple
OpenMaple/C/API
OpenMaple/C/Examples
rtable
Download Help Document