access the rtable data in external code
kernel handle returned by StartMaple
Maple rtable object
These functions are part of the OpenMaple interface to Microsoft Visual Basic.
The RTable*DataBlock family of functions return a 1-D copy of the data contained in rt. Modifying the returned data does not change the original rtable. The RTable*DataBlock function called must match the datatype of the rtable, which can be obtained from the data_type field of the RTableSettings structure returned by RTableGetSettings.
The specific RTableDataBlock function returns the address of the actual memory used by Maple to store the rtable data. This can be used to copy a changed data-block back and so update the rtable in Maple memory space.
The DoubleRTableDataBlock command provides a way to get the data of a datatype=float rtable in a native 2-D or 3-D Visual Basic format. A 2-D array returned can then be indexed via 2-D A(i,j) indexing instead of computing the equivalent A((j-1)*m+i-1) index into a 1-D array. In this case (i,j) will match the Maple index, usually starting at (1,1), whereas RTableF64DataBlock will always be offset from (0).
The data block of an rtable with an indexing function may not exactly match the way the data looks when viewed from Maple. For example, the data stored in position [1,1] of an rtable with a special indexing function may not correspond to the (0) element accessed from the rtable.
An error is raised if an attempt is made to get the data block from a Maple-sparse rtable.
Public Sub MySumElems(ByVal kv As Long)
Dim rts As RTableSettings
Dim rt As Long
Dim val As Double
Dim i As Long
' original rtable
rt = EvalMapleStatement(kv, "Matrix([[1,2,3],[4,5,6]],datatype=float);")
' ensure float datatype before choosing DataBlock function
RTableGetSettings kv, rts, rt
If rts.data_type = RTABLE_FLOAT64 Then
n = RTableNumElements(kv, rt)
ReDim data(0 To n - 1) As Double
data = RTableF64DataBlock(kv, rt)
' sum all the elements in rt
val = 0
For i = 0 To n - 1
val = val + data(i)
Write #1, "sum = ", val
Download Help Document