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

Online Help

All Products    Maple    MapleSim


RTableNumElements

query the number of elements in an rtable in external code

 

Calling Sequence

Parameters

Description

Examples

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<n; ++i ) {

        data[i] = val;

    }

    return( rt );

    }

Execute the external function from Maple.

withExternalCalling&colon;

dllExternalLibraryNameHelpExamples&colon;

setallDefineExternalMySetAllElems&comma;dll&colon;

MMatrix2&comma;datatype=float8&colon;

setallM&comma;3

3.3.3.3.

(1)

MMatrix2&comma;shape=triangularupper&comma;datatype=float8&colon;

setallM&comma;3

3.3.0.3.

(2)

MMatrix2&comma;storage=sparse2&comma;datatype=float8&colon;

setallM&comma;3

0.0.0.0.

(3)

M1,19

M1,19

(4)

setallM&comma;3

3.0.0.0.

(5)

See Also

CustomWrapper

define_external

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples

rtable