define_external(..., GENARGS=f, ...) - save an external procedure
|
Calling Sequence
|
|
define_external( functionName ..., GENARGS=f, ...)
|
|
Parameters
|
|
functionName
|
-
|
name of externally defined subroutine
|
f
|
-
|
procedure used to generate a partial argument list
|
|
|
|
|
Description
|
|
•
|
Procedures returned by the define_external command contain runtime information about the linkage to their corresponding external library. Instead of saving this information which is only valid for the current session, Maple saves the original parameter sequence passed to define_external. These parameters are used to regenerate the external procedure in the next Maple session.
|
•
|
The parameters used by define_external are not always machine independent. For example, on a Windows machine you may link to "mystuff.dll", while on a Linux box, the filename must be "libmystuff.so". Similarly, arguments may contain installation specific references to paths. Use the GENARGS=f option to specify a command to generate platform-specific arguments to define_external. This option is replaced by the return value of . This happens before processing of all arguments.
|
|
|
Examples
|
|
The following links to the Windows version of clapack.dll that comes with Maple. If you only ever use this function on Windows, it is fine to declare it in the usual way.
dgetrf := define_external('dgetrf_',
|
'm':REF(integer[4]),
|
'n':REF(integer[4]),
|
'a':ARRAY(float[8]),
|
'lda':REF(integer[4]),
|
'ipiv':ARRAY(integer[4]),
|
'info':REF(integer[4]),
|
'LIB'="clapack.dll"
|
):
|
|
|
If you want to use the same function on both Windows and Linux, you may want to declare it as follows.
dgetrf := define_external('dgetrf_',
|
'm':REF(integer[4]),
|
'n':REF(integer[4]),
|
'a':ARRAY(float[8]),
|
'lda':REF(integer[4]),
|
'ipiv':ARRAY(integer[4]),
|
'info':REF(integer[4]),
|
'GENARGS'=proc()
|
'LIB'=ExternalCalling:-ExternalLibraryName("clapack");
|
end proc
|
):
|
|
|
Other arguments can be returned as well as 'LIB'. When defining a named procedure, ensure it is saved.
clapack_args := proc( fn:string )
|
if fn = "dgetrf_" then
|
'm':REF(integer[4]),
|
'n':REF(integer[4]),
|
'a':ARRAY(float[8]),
|
'lda':REF(integer[4]),
|
'ipiv':ARRAY(integer[4]),
|
'info':REF(integer[4]),
|
'LIB'=ExternalCalling:-ExternalLibraryName("clapack");
|
end if;
|
end proc;
|
dgetrf := define_external("dgetrf_",'GENARGS'=clapack_args):
|
|
|
|
|