This package provides the ability to load and call "foreign" functions from shared libraries and to convert back and forth between Macaulay2 things and the foreign objects used by these functions. It is powered by libffi.
As a simple example, we call the cos
function from the C standard library, which sends a double
(a real number represented as a double-precision floating point number) to another double
, the cosine of the input.
|
|
|
In this example, we created a ForeignFunction
object using the foreignFunction constructor method and specified that both its output and input were instances of the double type, which is one of several ForeignType objects that are available.
See also the following additional examples:
This documentation describes version 0.4 of ForeignFunctions.
The source code from which this documentation is derived is in the file ForeignFunctions.m2.
The object ForeignFunctions is a package.