Download Maple Advanced Programming Guide

Transcript
6.2 External Calling: Using Compiled Code in Maple
•
361
created block of data, it is important that s->foreign is set to TRUE.
Size, storage, data type, order, and indexing functions should all be
considered when managing your data block. Generally, let Maple create the data-block, then use RtableDataBlock to gain access to it.
3. The bounds array, bounds. An m x n matrix must have bounds =
1,m,1,n (that is, both the upper and lower bounds must be specified).
The Fortran equivalent function is convert_to_rtable. It creates an
rtable from an existing Fortran array. The data is not copied into the
table. Instead, the rtable maintains a pointer to the external data.
RtableNumElements returns the number of elements in a given
rtable. This may be different in sparse versus dense rtables.
1. For dense rtables, return the number of elements of storage allocated
for this rtable.
2. If rt is in NAG-sparse format, then this returns the number of elements in the data vector specified for the rtable, (which is the same
as the length of each index vector). Note that the number returned
here represents the number of data elements that are actually filled
in, not the number of elements allocated. Some of the elements may
have the value zero.
3. For Maple-sparse rtables, this always returns zero.
RtableNumDimensions returns the number of dimensions in a given
rtable.
RtableUpperBound and RtableLowerBound give the upper and lower
bound of the dimth dimension of the RTABLE, rt. For a 2 x 3 matrix,
RtableLowerBound(rt,1) returns 1 because the first dimension bounds
are 1..2, and the lower bound is 1.
RtableIsReal checks the elements of the RTABLE rt to verify whether
they are all real. If datatype=complex, it returns FALSE. If datatype is
a hardware type with no indexing function, for example, float[8], it
returns TRUE. Otherwise, it scans the rtable and returns FALSE when the
first complex entry is found or TRUE if no complex entries are found.
In addition to the above functions, there is an extensive C API for
working with rtable data types.
void RTableAppendAttribute( MKernelVector kv, RTableSettings
*s, char *name );
void RTableAppendIndFn( MKernelVector kv, RTableSettings