RTableGetSettings
return a properties structure of an rtable in external code
RTableGetDefaults
return the default properties structure of an rtable in external code
Calling Sequence
Parameters
Description
Examples
RTableGetSettings(kv, rts, rt)
RTableGetDefaults(kv, rts)
kv
-
kernel handle of type MKernelVector
rts
pointer to an RTableSettings structure
rt
type ALGEB rtable object
These functions can be used in external code with OpenMaple or define_external.
RTableGetSettings assigns the properties of the rtable rt to the supplied RTableSettings structure.
RTableGetDefaults fills in the supplied RTableSettings structure with the default rtable properties, as implied by the rtable Maple command. The num_dimensions setting has no default value, and must always be set before creating an rtable.
The RTableSettings structure is defined in mpltable.h. It contains the following settings.
SETTING
TYPE
DEFAULT
EXPLANATION
data_type
int
RTABLE_DAG
type of data in the rtable.
maple_type
ALGEB
anything
type assertion on data
contained in rtables
with data_type=RTABLE_DAG.
subtype
RTABLE_ARRAY
type of rtable,
Array, Matrix, or Vector.
storage
RTABLE_RECT
storage layout.
p1,p2
M_INT
0
optional parameters used
by some storage layouts.
order
RTABLE_FORTRAN
C or Fortran order indexing
(set to RTABLE_FORTRAN,
or RTABLE_C).
read_only
M_BOOL
FALSE
disallow data writes when true.
foreign
true if external program
manages data memory. If the
pdata parameter to RTableCreate
is non-NULL, this field must be
set to TRUE.
num_dimensions
-1
a 5x5 rtable has 2 dimensions.
index_functions
MapleNULL
list of array indexing functions.
attributes
attributes given to this rtable.
transpose
when true, transpose
the rtable at creation.
fill
the default value for
unspecified elements.
The data_type field can have any of the following values.
Maple objects
RTABLE_CXDAG
ComplexFloatDAG
complex Maple objects
RTABLE_INTEGER8
char
8-bit integers
RTABLE_INTEGER16
short
16-bit integers
RTABLE_INTEGER32
32-bit integers
RTABLE_INTEGER64
long long
64-bit integers
RTABLE_FLOAT32
float
32-bit floating-point numbers
RTABLE_FLOAT64
double
64-bit floating-point numbers
RTABLE_COMPLEX
ComplexFloat64
64-bit complex float pair
The subtype field can have any of the following values.
Array
RTABLE_MATRIX
Matrix
RTABLE_COLUMN
column Vector
RTABLE_ROW
row Vector
The storage field can have any of the following values.
RTABLE_SPARSE
sparse format; a table
when data_type is RTABLE_DAG, otherwise
the index and data vector format used
by NAG. p2 can be set to RTABLE_SPARSE_UPPER
to exclude storing entries below the diagonal
using this format. Similarly, p2 can be set
to RTABLE_SPARSE_LOWER to exclude entries
above the diagonal. By default p2 is
RTABLE_SPARSE_DEFAULT, which allows storage
of all entries.
RTABLE_EMPTY
no storage (usually used in
combination with an indexing
function like IdentityMatrix where
the values can be derived without
needing to be stored.
RTABLE_DIAG
only the diagonal entries
are stored.
RTABLE_BAND
banded storage;
where p1 and p2 refer to the
number of non-zero subdiagonals
and superdiagonals.
dense rectangular storage.
RTABLE_UPPTRI
only the upper triangle
(including the diagonal) is stored.
RTABLE_UPPTRIMINUS
the upper triangle
excluding the diagonal is stored.
RTABLE_UPPTRIPLUS
plus the one subdiagonal is stored.
RTABLE_LOWTRI
only the lower triangle
RTABLE_LOWTRIMINUS
the lower triangle
RTABLE_LOWTRIPLUS
plus the one superdiagonal is stored.
RTABLE_SCALAR
a single entry is stored.
Usually the indexing function is used in conjunction with a non-dense storage. For example, identity is commonly used with RTABLE_EMPTY storage, and symmetric is commonly used with RTABLE_UPPTRI storage. The index_functions field can have any of the following values.
object of type ALGEB
the name or expression sequence of
indexing functions.
RTABLE_INDEX_ZERO
zero indexing function.
RTABLE_INDEX_BAND
band indexing function.
p1 and p2 must be set to indicate
the number of subdiagonals and
superdiagonals.
RTABLE_INDEX_CONSTANT
constant indexing function.
The fill value is used to denote
the constant stored in every entry
of the rtable. Usually used in
combination with RTABLE_EMPTY storage.
RTABLE_INDEX_DIAGONAL
diagonal indexing function.
RTABLE_INDEX_SCALAR
scalar indexing function.
Uses the fill value for the main
diagonal entry. If subtype is a
Vector format, then p1 is additionally
used to indicate which entry is filled
(instead of the diagonal).
RTABLE_INDEX_ANTIHERMITIAN
antihermitian indexing function.
RTABLE_INDEX_HERMITIAN
hermitian indexing function.
RTABLE_INDEX_UPPHESSEN
Hessenberg[upper] indexing function.
RTABLE_INDEX_LOWHESSEN
Hessenberg[lower] indexing function.
RTABLE_INDEX_IDENTITY
identity indexing function.
RTABLE_INDEX_ANTISYMMETRIC
antisymmetric indexing function.
RTABLE_INDEX_SYMMETRIC
symmetric indexing function.
RTABLE_INDEX_LOWTRI
triangular[lower] indexing function.
RTABLE_INDEX_UPPTRI
triangular[upper] indexing function.
RTABLE_INDEX_UNIUPPTRI
triangular[upper,unit] indexing function.
RTABLE_INDEX_UNILOWTRI
triangular[lower,unit] indexing function.
RTABLE_INDEX_UNIT
unit indexing function.
#include <stdlib.h>
#include "maplec.h"
ALGEB M_DECL MyRandomDiagonal( MKernelVector kv, ALGEB *args )
{
M_INT argc, n, i;
RTableSettings rts;
M_INT bounds[4];
ALGEB rt;
INTEGER32 *data, slice;
FLOAT64 density;
argc = MapleNumArgs(kv,(ALGEB)args);
if( argc != 2 ) {
MapleRaiseError(kv,"two arguments expected");
return( NULL );
}
n = MapleToM_INT(kv,args[1]);
density = MapleToFloat64(kv,args[2]);
slice = (INTEGER32)(density * 32767);
RTableGetDefaults(kv,&rts);
rts.num_dimensions = 2;
rts.subtype = RTABLE_MATRIX;
rts.data_type = RTABLE_INTEGER32;
rts.storage = RTABLE_DIAG;
rts.index_functions = (ALGEB)RTABLE_INDEX_DIAGONAL;
rts.fill = ToMapleInteger(kv,-1);
rts.order = RTABLE_C;
rts.read_only = TRUE;
rts.attributes = ToMapleName(kv,"MyRand",TRUE);
bounds[0] = 1;
bounds[1] = n;
bounds[2] = 1;
bounds[3] = n;
rt = RTableCreate(kv,&rts,NULL,bounds);
data = (INTEGER32*)RTableDataBlock(kv,rt);
for( i=0; i<n; ++i ) {
if( rand() % 32767 <= slice )
data[i] = rand();
return( rt );
Execute the external function from Maple.
with⁡ExternalCalling:
dll≔ExternalLibraryName⁡HelpExamples:
diag≔DefineExternal⁡MyRandomDiagonal,dll:
M≔diag⁡6,0.6
M≔18984548200000008398028060000001678790852000000−1000000−1000000−1
M1,1≔9
Error, cannot assign to a read-only Matrix
See Also
CustomWrapper
define_external
OpenMaple
OpenMaple/C/API
OpenMaple/C/Examples
rtable
Download Help Document