RTableNumElements - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

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

 • 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.

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

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{setall}≔\mathrm{DefineExternal}\left("MySetAllElems",\mathrm{dll}\right):$
 > $M≔\mathrm{Matrix}\left(2,\mathrm{datatype}=\mathrm{float}\left[8\right]\right):$
 > $\mathrm{setall}\left(M,3\right)$
 $\left[\begin{array}{cc}{3.}& {3.}\\ {3.}& {3.}\end{array}\right]$ (1)
 > $M≔\mathrm{Matrix}\left(2,\mathrm{shape}=\mathrm{triangular}\left[\mathrm{upper}\right],\mathrm{datatype}=\mathrm{float}\left[8\right]\right):$
 > $\mathrm{setall}\left(M,3\right)$
 $\left[\begin{array}{cc}{3.}& {3.}\\ {0.}& {3.}\end{array}\right]$ (2)
 > $M≔\mathrm{Matrix}\left(2,\mathrm{storage}=\mathrm{sparse}\left[2\right],\mathrm{datatype}=\mathrm{float}\left[8\right]\right):$
 > $\mathrm{setall}\left(M,3\right)$
 $\left[\begin{array}{cc}{0.}& {0.}\\ {0.}& {0.}\end{array}\right]$ (3)
 > $M\left[1,1\right]≔9$
 ${{M}}_{{1}{,}{1}}{≔}{9}$ (4)
 > $\mathrm{setall}\left(M,3\right)$
 $\left[\begin{array}{cc}{3.}& {0.}\\ {0.}& {0.}\end{array}\right]$ (5)