MapleToGMPInteger
get the underlying GMP integer from a Maple integer
Calling Sequence
Parameters
Description
Examples
MapleToGMPInteger(kv, s)
kv
-
kernel handle of type MKernelVector
s
Maple integer of type ALGEB
The MapleToGMPInteger function returns a pointer to the GMP integer used to represent the Maple integer s. The pointer returned is of type mpz_ptr.
The GMP integer returned may be the actual GMP integer used by Maple. Thus these variables should only be used for reading, never writing.
If you are using GMP in your external library, you should use MaplePushGMPAllocators to set your own memory allocator functions.
#include <stdlib.h>
#include "maplec.h"
#include "gmp.h"
ALGEB M_DECL PrintInt( MKernelVector kv, ALGEB *args )
{
mpz_ptr gmp_ptr;
char buf[1024];
if ( IsMapleInteger( kv, args[1] ) )
gmp_ptr = MapleToGMPInteger( kv, args[1] );
MapleALGEB_Printf( kv, "m %d\n", args[1] );
gmp_sprintf( buf, "g %Zd\n", gmp_ptr );
MaplePrintf( kv, "%s", buf );
}
return ToMapleNULL( kv );
Execute the external function from Maple.
with⁡ExternalCalling:
dll≔ExternalLibraryName⁡HelpExamples:
PrintInt≔DefineExternal⁡PrintInt,dll:
PrintInt⁡0
m 0 g 0
PrintInt⁡1
m 1 g 1
PrintInt⁡106
m 1000000 g 1000000
PrintInt⁡7128
m 1487815647197611695910312681741273570332356717154798949898498305086387315423300999654757561928633305897036801 g 1487815647197611695910312681741273570332356717154798949898498305086387315423300999654757561928633305897036801
See Also
CustomWrapper
define_external
OpenMaple
OpenMaple/C/API
Download Help Document