MapleUnique - Maple Help

Home : Support : Online Help : Programming : OpenMaple : VB Application Programming Interface : Evaluation and Error Handling : OpenMaple/VB/MapleUnique

MapleUnique

return unique copy of an object in external code

 Calling Sequence MapleUnique(kv, s)

Parameters

 kv - kernel handle returned by StartMaple s - Maple object

Description

 • This function is part of the OpenMaple interface to Microsoft Visual Basic.
 • The MapleUnique function processes the Maple expression, s, and returns the unique normalized copy of that expression. For example, if you create the number num = one-billion, and then compute the number val = 2*500-million, an address comparison of num and val does not indicate equality. For example, after calling num = MapleUnique(kv,num);, both num and val point to the same memory.
 • Because Maple maintains a table of unique elements, only one copy of most objects exists in memory.  The expression ${x}^{2}+x$ contains two references to $x$, but both point to the same object.  Similarly, $\left[\left[1,2\right],\left[1,2\right]\right]$ contains two sublists, $\left[1,2\right]$.  The surrounding list maintains two pointers to the same sublist.  It is usually not safe to directly modify any object that has been processed by Maple. For example, if the sublist were changed from $\left[1,2\right]$ to $\left[3,2\right]$, the parent list also changes.  In fact, all references to the list $\left[1,2\right]$ in Maple would then point to $\left[3,2\right]$. This would cause many problems. For example, table lookups of the $\left[1,2\right]$ element would be changed to look up the $\left[3,2\right]$ element.  It is safe to directly modify only data blocks of mutable objects like rtables and tables.  Never change strings returned by MapleToString, or expression sequences like the args object given to the external entry point.

Examples

 Sub TestConvertToMaple(ByVal kv As Long) Dim list, args As Long list = MapleListAlloc(kv, 15) 'MapleGcProtect kv, list MapleListAssign kv, list, 1, ToMapleBoolean(kv, 1) MapleListAssign kv, list, 2, ToMapleBoolean(kv, 0) MapleListAssign kv, list, 3, ToMapleBoolean(kv, -1) MapleListAssign kv, list, 4, ToMapleBoolean(kv, 2) MapleListAssign kv, list, 5, ToMapleChar(kv, "M") MapleListAssign kv, list, 6, ToMapleComplex(kv, 1.1, 2.2) MapleListAssign kv, list, 7, ToMapleComplexFloat(kv, _ ToMapleFloat(kv, 3.3), ToMapleFloat(kv, 4.4)) MapleListAssign kv, list, 8, ToMapleInteger(kv, 98765) MapleListAssign kv, list, 9, ToMapleFloat(kv, 3.1415) args = NewMapleExpressionSequence(kv, 2) MapleExpseqAssign kv, args, 1, ToMapleName(kv, "x", True) MapleExpseqAssign kv, args, 2, ToMapleName(kv, "x", True) MapleListAssign kv, list, 10, ToMapleFunction(kv, _ ToMapleName(kv, "int", True), args) MapleListAssign kv, list, 11, ToMapleNULLPointer(kv) MapleListAssign kv, list, 12, ToMapleRelation(kv, ">", _ ToMapleName(kv, "X", True), ToMapleInteger(kv, 1)) MapleListAssign kv, list, 13, ToMapleString(kv, "A string") MapleListAssign kv, list, 14, ToMapleUneval(kv, _ ToMapleName(kv, "Z", True)) MapleListAssign kv, list, 15, ToMapleNULL(kv) 'note this will get removed when the list is flattened MapleALGEB_Printf1 kv, "%a", MapleUnique(kv, list) End Sub