MapleToGMPInteger - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


MapleToGMPInteger

get the underlying GMP integer from a Maple integer

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MapleToGMPInteger(kv, s)

Parameters

kv

-

kernel handle of type MKernelVector

s

-

Maple integer of type ALGEB

Description

• 

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.

Examples

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

withExternalCalling&colon;

dllExternalLibraryNameHelpExamples&colon;

PrintIntDefineExternalPrintInt&comma;dll&colon;

PrintInt0

m 0
g 0

PrintInt1

m 1
g 1

PrintInt106

m 1000000
g 1000000

PrintInt7128

m 1487815647197611695910312681741273570332356717154798949898498305086387315423300999654757561928633305897036801
g 1487815647197611695910312681741273570332356717154798949898498305086387315423300999654757561928633305897036801

See Also

CustomWrapper

define_external

OpenMaple

OpenMaple/C/API