RTableNumElements - query the number of elements in an rtable in external code
|
Calling Sequence
|
|
RTableNumElements(kv, rt)
|
|
Parameters
|
|
kv
|
-
|
kernel handle of type MKernelVector
|
rt
|
-
|
type ALGEB rtable object
|
|
|
|
|
Description
|
|
•
|
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.
|
|
|
Examples
|
|
#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");
|
return( NULL );
|
}
|
rt = args[1];
|
RTableGetSettings(kv,&rts,rt);
|
if( rts.data_type != RTABLE_FLOAT64 ) {
|
MapleRaiseError(kv,"float[8] rtable expected for parameter 1");
|
return( NULL );
|
}
|
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.
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
>
|
|
| (2) |
>
|
|
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
|
|
Download Help Document
Was this information helpful?