RTableLowerBound - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : OpenMaple : C Application Programming Interface : RTable Manipulation : OpenMaple/C/RTableBounds

RTableLowerBound

query the lower bound of the ith dimension of an rtable in external code

RTableUpperBound

query the upper bound of the ith dimension of an rtable in external code

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

RTableLowerBound(kv, rt, dim)

RTableUpperBound(kv, rt, dim)

Parameters

kv

-

kernel handle of type MKernelVector

rt

-

type ALGEB rtable object

dim

-

integer specifying dimension

Description

• 

This functions can be used in external code with OpenMaple or define_external.

• 

RTableLowerBound returns the lower bound of dimension dim for the given rtable, rt.  For rtables with subtype Matrix and Vector, this always returns 1.  For Arrays, this command is equivalent to calling lhs([rtable_dims(A)][dim]), or op([2,dim,1],rt).

• 

RTableUpperBound returns the upper bound of dimension dim for the given rtable, rt.  For rtables with subtype Matrix and Vector, this is equivalent to to calling op([1,dim],rt). For Arrays, this command is equivalent to calling op([2,dim,2],rt). For all rtables, it is equivalent to calling rhs([rtable_dims(A)][dim]).

Examples

    #include "maplec.h"

    ALGEB M_DECL MyReindexRTable( MKernelVector kv, ALGEB *args )

    {

    M_INT argc, i, num_dims, n, bounds[RTABLE_MAX_BOUNDS];

    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 );

        }

    if( rts.storage == RTABLE_SPARSE ) {

        MapleRaiseError(kv,"dense rtable expected for parameter 1");

            return( NULL );

        }

    num_dims = RTableNumDimensions(kv,rt1);

    for( i=1; i<=num_dims; ++i ) {

        bounds[2*i-2] = 1;

        bounds[2*i-1] = RTableUpperBound(kv,rt1,i)

         - RTableLowerBound(kv,rt1,i) + 1;

    }

    rt2 = RTableCreate(kv,&rts,NULL,bounds);

    n = RTableNumElements(kv,rt1);

    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;

reindexDefineExternalMyReindexRTable&comma;dll&colon;

AArray32..34&comma;111..113&comma;i&comma;j&rarr;3i1&plus;j

A:=Array32..34&comma;111..113&comma;32&comma;111&equals;204&comma;32&comma;112&equals;205&comma;32&comma;113&equals;206&comma;33&comma;111&equals;207&comma;33&comma;112&equals;208&comma;33&comma;113&equals;209&comma;34&comma;111&equals;210&comma;34&comma;112&equals;211&comma;34&comma;113&equals;212

(1)

BreindexA

B:=204205206207208209210211212

(2)

A32&comma;111

204

(3)

B1&comma;1

204

(4)

See Also

CustomWrapper

define_external

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples

rtable

rtable_dims

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam