11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

myAdd = to_maple_integer( kv, r )END7.2 Using Compiled Code in Maple • 319Once compiled into a DLL, the same syntax can be used in Mapleto access the function. The only difference is the additional keyword’FORTRAN’ in the define_external call.> myAdd := define_external(’myAdd’,’MAPLE’,’FORTRAN’,’LIB’=> "myAdd.dll"):> myAdd(2,3);5External APIAn external API is provided for users who want to augment existingwrappers or write their own custom wrappers. This section describes thefunctions available when linking with the Maple API library (see Table 7.4on page 340) and including either maplec.h or maplefortran.hf.Argument Checking The following C function can be used to querythe number of arguments contained in the argument expression sequencepassed as the last argument to the external function entry point. Theexpression sequence passed to this entry point can be queried directly (forexample, ((ALGEB*)expr)[1]). If n = MapleNumArgs(kv,expr), the lastargument is ((ALGEB*)expr[n].M_INT MapleNumArgs( MKernelVector kv, ALGEB expr );The arguments passed to the Fortran entry point cannot be querieddirectly. The maple_extract_arg function must be used to access theargument data (for example, arg1 = maple_extract_arg(kv,args,1)).If n = maple_num_args(kv,s), then the last argument ismaple_extract_arg(kv,args,n).INTEGER maple_num_args( kv, s )INTEGER maple_extract_arg( kv, s, i )The following functions indicate the type of the given Maple object.M_BOOL IsMapleAssignedName( MKernelVector kv, ALGEB s );M_BOOL IsMapleComplexNumeric( MKernelVector kv, ALGEB s );M_BOOL IsMapleNumeric( MKernelVector kv, ALGEB s );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!