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

Online Help

All Products    Maple    MapleSim


RTableNumDimensions

query the number of dimensions of an rtable in external code

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

RTableNumDimensions(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.

• 

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.

withExternalCalling&colon;

dllExternalLibraryNameHelpExamples&colon;

flattenDefineExternalMyFlattenRTable&comma;dll&colon;

MMatrix3&comma;i&comma;j3i3+j

M123456789

(1)

flattenM

147258369

(2)

MMatrix3&comma;i&comma;j3i3+j&comma;order=C_order

M123456789

(3)

flattenM

123456789

(4)

See Also

CustomWrapper

define_external

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples

rtable

rtable_num_dims