MapleToComplexFloat32 - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : C Application Programming Interface : Conversions from Maple Objects : OpenMaple/C/ConvertFromMaple

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 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)

Parameters

 kv - kernel handle of type MKernelVector s - Maple object of type ALGEB

Description

 • 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.

Examples

 #include #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.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{cmp}≔\mathrm{DefineExternal}\left("MyCompare",\mathrm{dll}\right):$
 > $\mathrm{cmp}\left(">",3.13,3.14\right)$
 Comparing 3.130000 > 3.140000
 ${\mathrm{false}}$ (1)
 > $\mathrm{cmp}\left("=",\mathrm{evalf}\left(\mathrm{π},30\right),\mathrm{evalf}\left(\mathrm{π},40\right)\right)$
 Comparing 3.141593 = 3.141593
 ${\mathrm{true}}$ (2)
 > $\mathrm{cmp}\left("!=",1,0\right)$
 Comparing 1.000000 != 0.000000
 ${\mathrm{FAIL}}$ (3)

 See Also

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam