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

# Online Help

###### All Products    Maple    MapleSim

RTableIndFn

retrieve an indexing function code in external code

RTableIndFnArgs

retrieve arguments for an indexing function code in external code

 Calling Sequence RTableIndFn(kv, rt, i) RTableIndFnArgs(kv, rt, i)

Parameters

 kv - kernel handle of type MKernelVector rt - type ALGEB rtable object i - ith indexing function in an rtable

Description

 • These functions can be used in external code with OpenMaple or define_external.
 • RTableIndFn returns the RTABLE_INDEX_* code denoting the kind of indexing function used by the rtable rt.  Since rtables can have more than one indexing function, the parameter i specifies which index function to examine.  Use MapleNumArgs on the RTableSettings indexing_functions field to determine the number of indexing functions an rtable has.  Typically an rtable has no indexing functions.
 • Some indexing functions have extra data associated with them.  For example band is usually denoted band[p1,p2] where p1 and p2 are the number of diagonals above and below the main diagonal.  These extra arguments can be retrieved using RTableIndFnArgs.

Examples

 #include #include "maplec.h" ALGEB M_DECL MySetDiagonal( MKernelVector kv, ALGEB *args ) { M_INT argc, i, diag, size, index[2], num_iter; RTableSettings rts; RTableData rtd; ALGEB rt; argc = MapleNumArgs(kv,(ALGEB)args); if( argc != 3 ) { MapleRaiseError(kv,"three arguments expected"); return( NULL ); } rt = args[1]; if( !IsMapleRTable(kv,rt) ) { MapleRaiseError(kv,"rtable expected"); return( NULL ); } RTableGetSettings(kv,&rts,rt); if( rts.data_type != RTABLE_FLOAT64 ) { MapleRaiseError(kv,"float[8] rtable expected"); return( NULL ); } if( rts.num_dimensions != 2 ) { MapleRaiseError(kv,"2D rtable expected"); return( NULL ); } if( RTableUpperBound(kv,rt,1) != RTableUpperBound(kv,rt,2) || RTableLowerBound(kv,rt,1) != 1 || RTableLowerBound(kv,rt,2) != 1 ) { MapleRaiseError(kv, "square rtable with indexing starting at 1 expected"); return( NULL ); } rtd.float64 = MapleToFloat64(kv,args[3]); diag = MapleToM_INT(kv,args[2]); size = RTableUpperBound(kv,rt,1) - RTableLowerBound(kv,rt,1) + 1; if( diag > size-1 ) return( rt ); if( diag < 0 ) { index[0] = 1; index[1] = -diag+1; num_iter = size - index[1] + 1; } else { index[0] = diag+1; index[1] = 1; num_iter = size - index[0] + 1; } if( MapleNumArgs(kv,rts.index_functions) == 1 && RTableIndFn(kv,rt,1) == RTABLE_INDEX_BAND && rts.order == RTABLE_FORTRAN && rts.storage == RTABLE_BAND ) { M_INT p1, p2, j; ALGEB band_args; FLOAT64 *data; band_args = RTableIndFnArgs(kv,rt,1); p1 = MapleToM_INT(kv,(ALGEB)band_args[1]); p2 = MapleToM_INT(kv,(ALGEB)band_args[2]); if( p1 == rts.p1 && p2 == rts.p2 ) { if( (diag < 0 && -diag > p2) || (diag > 0 && diag > p1) ) { MapleRaiseError(kv,"diagonal outside of bands"); return( NULL ); } data = (FLOAT64*)RTableDataBlock(kv,rt); j = MATRIX_OFFSET_FORTRAN_BAND(index[0],index[1], size,size,p1,p2); for( i=0; i

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{setdiag}≔\mathrm{DefineExternal}\left("MySetDiagonal",\mathrm{dll}\right):$
 > $M≔\mathrm{Matrix}\left(5,5,\left(i,j\right)→5\left(i-1\right)+j,\mathrm{shape}={\mathrm{band}}_{1,2},\mathrm{datatype}={\mathrm{float}}_{8}\right)$
 ${M}{≔}\left[\begin{array}{ccccc}{1.}& {2.}& {3.}& {0.}& {0.}\\ {6.}& {7.}& {8.}& {9.}& {0.}\\ {0.}& {12.}& {13.}& {14.}& {15.}\\ {0.}& {0.}& {18.}& {19.}& {20.}\\ {0.}& {0.}& {0.}& {24.}& {25.}\end{array}\right]$ (1)
 > $\mathrm{setdiag}\left(M,-2,55\right)$
 $\left[\begin{array}{ccccc}{1.}& {2.}& {55.}& {0.}& {0.}\\ {6.}& {7.}& {8.}& {55.}& {0.}\\ {0.}& {12.}& {13.}& {14.}& {55.}\\ {0.}& {0.}& {18.}& {19.}& {20.}\\ {0.}& {0.}& {0.}& {24.}& {25.}\end{array}\right]$ (2)
 > $\mathrm{setdiag}\left(M,-1,66\right)$
 $\left[\begin{array}{ccccc}{1.}& {66.}& {55.}& {0.}& {0.}\\ {6.}& {7.}& {66.}& {55.}& {0.}\\ {0.}& {12.}& {13.}& {66.}& {55.}\\ {0.}& {0.}& {18.}& {19.}& {66.}\\ {0.}& {0.}& {0.}& {24.}& {25.}\end{array}\right]$ (3)
 > $\mathrm{setdiag}\left(M,0,77\right)$
 $\left[\begin{array}{ccccc}{77.}& {66.}& {55.}& {0.}& {0.}\\ {6.}& {77.}& {66.}& {55.}& {0.}\\ {0.}& {12.}& {77.}& {66.}& {55.}\\ {0.}& {0.}& {18.}& {77.}& {66.}\\ {0.}& {0.}& {0.}& {24.}& {77.}\end{array}\right]$ (4)
 > $\mathrm{setdiag}\left(M,1,88\right)$
 $\left[\begin{array}{ccccc}{77.}& {66.}& {55.}& {0.}& {0.}\\ {88.}& {77.}& {66.}& {55.}& {0.}\\ {0.}& {88.}& {77.}& {66.}& {55.}\\ {0.}& {0.}& {88.}& {77.}& {66.}\\ {0.}& {0.}& {0.}& {88.}& {77.}\end{array}\right]$ (5)
 > $M≔\mathrm{Matrix}\left(5,5,\mathrm{fill}=1,\mathrm{shape}=\mathrm{symmetric},\mathrm{datatype}={\mathrm{float}}_{8}\right)$
 ${M}{≔}\left[\begin{array}{ccccc}{1.}& {1.}& {1.}& {1.}& {1.}\\ {1.}& {1.}& {1.}& {1.}& {1.}\\ {1.}& {1.}& {1.}& {1.}& {1.}\\ {1.}& {1.}& {1.}& {1.}& {1.}\\ {1.}& {1.}& {1.}& {1.}& {1.}\end{array}\right]$ (6)
 > $\mathrm{setdiag}\left(M,1,99\right)$
 $\left[\begin{array}{ccccc}{1.}& {99.}& {1.}& {1.}& {1.}\\ {99.}& {1.}& {99.}& {1.}& {1.}\\ {1.}& {99.}& {1.}& {99.}& {1.}\\ {1.}& {1.}& {99.}& {1.}& {99.}\\ {1.}& {1.}& {1.}& {99.}& {1.}\end{array}\right]$ (7)

 See Also