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.

314 • Chapter 7: <strong>Advanced</strong> Connectivityfunction vector. The second argument fn is a function pointer assignedthe symbol found in the external DLL. In this case, fn is assigned thequadruple_it external function. The last argument is a Maple expressionsequence data structure containing all the arguments passed to thefunction during any given call to the Maple procedure generated by thedefine_external command.The entry point is the format used when wrappers are automaticallygenerated, and when WRAPLIB is specified. An alternate external entrypoint that excludes the function pointer is available when the parameterMAPLE is specified instead of WRAPPER or WRAPLIB.ALGEB MWRAP_quadruple_it(MKernelVector kv,ALGEB fn_args);The API function prototypes for manipulating Maple data structuresare in $MAPLE/extern/include where $MAPLE is the path of your Mapleinstallation. The header file maplec.h should be included when writingcustom C wrappers. One of the header files, maplefortran.hf ormaplefortran64bit.hf, should be included when writing custom Fortranwrappers. Other header files, mplshlib.h, and mpltable.h containmacros, types, and data structures that are needed for direct manipulationof Maple data structures.Maple uses directed acyclic graphs (dags) to represent all objects,such as integers, floating point numbers, sums, modules, or procedures.(For more information about Maple internal representation of objects,see Appendix A.) These dags have the type ALGEB in C wrappers, andINTEGER or INTEGER*8 in Fortran wrappers. Fortran 77 has no user typedefinition semantics so ALGEB pointers must be “faked” by using machineword-sized integers. If the machine word size is 64-bit (for example,as on a DEC Alpha), the header maplefortran64bit.hf must be usedand INTEGER*8 must be used as the dag datatype. Execute the Maplecommand kernelopts(wordsize) to determine whether you need to use32-bit or 64-bit integer-dag types in Fortran. When working with C, thedatatype is ALGEB regardless of the machine word size.You do not have to know the internal details of dags to manipulateand use them. The only exception is the argument sequence passed tothe wrapper entry point. This is an expression seqence (EXPSEQ) dag, andcan be treated as an array of dags starting at index 1 (not 0). Thus,fn_args[1] is the first parameter passed to the external function. UseMapleNumArgs to determine the number of arguments passed. Note that

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

Saved successfully!

Ooh no, something went wrong!