|
|
Application Program Interface
|
|
|
=============================
|
|
|
|
|
|
## General Advice
|
|
|
|
|
|
The following techniques for using the API are advised:
|
|
|
|
|
|
- Find the appropriate function(s) in the [GSL documentation](http://www.gnu.org/software/gsl/manual/).
|
|
|
- Use the GSLL function `gsl-lookup` to find the equivalent GSLL function, for example
|
|
|
|
|
|
(gsl:gsl-lookup "gsl_sf_elljac_e")
|
|
|
JACOBIAN-ELLIPTIC-FUNCTIONS
|
|
|
T
|
|
|
|
|
|
to find that the Lisp function name is `#'jacobian-elliptic-functions`.
|
|
|
|
|
|
- Look at the documentation for that Lisp function, e.g.
|
|
|
|
|
|
(documentation #'jacobian-elliptic-functions 'function)
|
|
|
"The Jacobian elliptic functions sn(u|m),
|
|
|
cn(u|m), dn(u|m) computed by descending Landen transformations."
|
|
|
|
|
|
|
|
|
to get an explanation of the arguments etc.
|
|
|
|
|
|
- Use the function `(examples)` without an argument to get a list of example categories. Then use the function with a category name as the argument to get a list of examples under that category, for example `(examples 'higher-moments)`. The result will be a list of forms, each providing an example of usage in the relevant topic. If the [GSL documentation](http://www.gnu.org/software/gsl/manual/) provides an example, there will usually be the same or similar example provided in GSLL. *Note:* Some of the examples are intentionally designed to signal an error, because the examples also serve as a regression (unit) test suite for GSLL.
|
|
|
|
|
|
Some examples are not yet present in, or are too complicated for, the function `#'examples`. In this case, you need to look in the relevant source file; they are in either a separate file of examples, or at the end of the file of definitions. It is advisable to look at the examples first for calculations that require more complex setup (generally, the later chapters in the GSL manual).
|
|
|
|
|
|
## Arrays
|
|
|
|
|
|
GSLL has many functions that work on vectors (one-dimensional arrays) and matrices (two-dimensional arrays). Foreign arrays are defined and manipulated using _grid_ definitions in [Antik](http://www.common-lisp.net/project/antik/) which defines generic operations on array-like objects; see the Antik documentation for more information. GSLL supports all array element types that are supported by CFFI, the CL implementation, GSL, and the platform. This list is available in the variable `grid:*array-element-types*`.
|
|
|
|
|
|
## Passing functions
|
|
|
|
|
|
Functions that are passed to GSL functions (known as *callbacks* in C) are specified with a [function designator](http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_f.htm#function_designator) for the CL function, that is, either the function object itself or a symbol denoting the function. There is usually an option `scalarsp` for functions that take or return arrays that, if true, will send the user function the argument element by element, and expect the return values to be the individual elements.
|
|
|
|
|
|
## Additional definitions
|
|
|
|
|
|
Some definitions are provided because of their usefulness, even though GSL doesn't have them.
|
|
|
|
|
|
- `invert-matrix` finds the inverse of a matrix and uses GSL's LU decomposition functions.
|
|
|
- IEEE floating point number analysis.
|
|
|
- `fft-frequency-vector` returns a vector where the sample frequencies are contained. If you perform an FFT on a vector of a given size and :sample-size, this vector will contain the sample frequencies in order. If the :shifted keyword is T, then the frequencies are ordered in ascending order.
|
|
|
- `fft-shift` returns a copy of a vector where the zero frequency has been shifted to the center; the frequency components will be sorted according to their frequency, in ascending order. Optionally, a :stride can be provided.
|
|
|
- `fft-inverse-shift` performs the inverse action of fft-shift; the zero and positive frequency components are shifted to the beginning, so that the resulting vector is suitable for an inverse FFT. Optionally, a :stride can be provided. |