MapleToComplexFloat32
convert a Maple object to a 32-bit complex float pair
MapleToComplexFloat64
convert a Maple object to a 64-bit complex float pair
MapleToComplexFloatDAG
convert a Maple object to a complex software float pair
MapleToFloat32
convert a Maple object to a 32-bit float
MapleToFloat64
convert a Maple object to a 64-bit float
MapleToInteger8
convert a Maple object to a 8-bit integer
MapleToInteger16
convert a Maple object to a 16-bit integer
MapleToInteger32
convert a Maple object to a 32-bit integer
MapleToInteger64
convert a Maple object to a 64-bit integer
MapleToM_BOOL
convert a Maple object to a hardware boolean
MapleToM_INT
convert a Maple object to a machine word sized integer
MapleToPointer
return the embedded pointer from Maple pointer object
MapleToString
convert a Maple object to a character array
Calling Sequence
Parameters
Description
Examples
MapleToComplexFloat32(kv, s)
MapleToComplexFloat64(kv, s)
MapleToComplexFloatDAG(kv, s)
MapleToFloat32(kv, s)
MapleToFloat64(kv, s)
MapleToInteger8(kv, s)
MapleToInteger16(kv, s)
MapleToInteger32(kv, s)
MapleToInteger64(kv, s)
MapleToM_BOOL(kv, s)
MapleToM_INT(kv, s)
MapleToPointer(kv, s)
MapleToString(kv, s)
kv
-
kernel handle of type MKernelVector
s
Maple object of type ALGEB
These functions can be used in external code with OpenMaple or define_external.
The MapleTo* functions convert a Maple object to a hardware data structure format. The return values are defined in the supplied header files.
Floating-point numbers may lose precision during the conversion to hardware size data.
Conversion from a Maple string object to an integer returns the ASCII value of the first character in that string. Conversion from a Maple boolean to an integer returns 1 for true, 0 for false, and -1 for FAIL.
The C version of MapleToString returns the same character array pointer referenced in the given Maple object. This string must not be modified in-place. Modifications must be made on a copy, not the original string returned by MapleToString.
The MapleToPointer conversion returns the pointer given as the first argument of ToMaplePointer. For more information about this data structure, see ?MaplePointer.
Some native types are defined in the header file mplshlib.h. The types M_INT and M_BOOL are often used for word-sized integer and boolean values. Other types are defined in mpltable.h, including complex structs, and macros for fixed bit size integers.
#include <stdlib.h>
#include "maplec.h"
ALGEB M_DECL MyCompare( MKernelVector kv, ALGEB *args )
{
M_INT argc;
FLOAT64 a, b;
char *op;
argc = MapleNumArgs(kv,(ALGEB)args);
if( argc != 3 ) {
MapleRaiseError(kv,"three arguments expected");
return( NULL );
}
op = MapleToString(kv,args[1]);
a = MapleToFloat64(kv,args[2]);
b = MapleToFloat64(kv,args[3]);
MaplePrintf(kv,"Comparing %f %s %fn",a,op,b);
switch( op[0] ) {
case '>': return( ToMapleBoolean(kv,a > b) );
case '<': return( ToMapleBoolean(kv,a < b) );
case '=': return( ToMapleBoolean(kv,a == b) );
return( ToMapleBoolean(kv,-1) );
Execute the external function from Maple.
with⁡ExternalCalling:
dll≔ExternalLibraryName⁡HelpExamples:
cmp≔DefineExternal⁡MyCompare,dll:
cmp⁡>,3.13,3.14
Comparing 3.130000 > 3.140000
false
cmp⁡=,evalf⁡π,30,evalf⁡π,40
Comparing 3.141593 = 3.141593
true
cmp⁡!=,1,0
Comparing 1.000000 != 0.000000
FAIL
See Also
CustomWrapper
define_external
OpenMaple
OpenMaple/C/API
Download Help Document