Scientific Computing Lisp (abbreviated “SciCL” and pronounced “cycle”) is an extensible symbolic, numerical, graphical and auditory programming environment embedded in ANSI Common Lisp (“CL”). SciCL provides a set of Common Lisp language extensions that support high-performance scientific computing on numerical collections.
SciCL augments Common Lisp with an extensive library of aggregate-wise (“AG-wise”) operations on arrays, providing the essential functionality of languages such as APL, Fortran 90, IDL and Matlab. These operations enable concise, linear algebraic description of many iterative and recursive algorithms that operate on rectilinear arrays, irregular data structures and nested collections.
The AG-wise, linear algebraic style of describing scientific computations offers significant advantages over element-wise (“EL-wise”) specification using general purpose programming languages (such as C and earlier dialects of Fortran). For example, the recursive, radix-two “decimation in time” Gauss-Cooley-Tukey fast Fourier transform algorithm coded in SciCL looks like:
(defun RADIX-2-FFT (X) (let ((N (SIZE X))) (if (= N 2) (JOIN (+ (cref X 0) (cref X 1)) (- (cref X 0) (cref X 1))) (let ((X-even (RADIX-2-FFT (EVEN X))) (X-odd (~* (RADIX-2-FFT (ODD X)) (ROOTS (/ N 2))))) (JOIN (~+ X-even X-odd) (~- X-even X-odd))))))
JOIN concatenates scalar or vector arguments, while ROOTS retrieves (or computes on-the-fly) a subset of the complex roots of unity. A typical EL-wise specification of RADIX-2-FFT requires about fifty lines of Fortran 77 code.
SciCL provides four categories of operators on collections: generators, transformers, selectors and reducers.
SciCL transformers re-map individual elements of operand collections one-to- one onto corresponding elements of a returned collection. The largest group of SciCL transformers extend Common Lisp’s fundamental EL-wise arithmetic operations across higher-dimensional numerical collections (for example, multi-dimensional addition (~+), subtraction (~-) and multiplication (~* ) operators in RADIX-2-FFT above).
SciCL’s multi-dimensional arithmetic extensions are referenced in user function namespace by pre-pending a tilde “~” to the name of a Common Lisp arithmetic operator (for example, the linear algebraic extension of CL “+” is denoted “~+”). This “tilde” family of SciCL operators inherits the same rules of number type contagion and coercion supported by the user’s host Lisp implementation.
SciCL selectors extract and/or re-order designated subsets of generalized collections. Selectors thus may potentially alter the shape and/or size of an operand collection. Some typical examples of selectors include: REV(erse), DECIMATE, ROTATE, SUBARRAY, GATHER (and JOIN in RADIX-2-FFT above).
SciCL generators provide the collective functionality of
Matlab’s “colon” notation, Fortran 90’s “paren/colon” syntax, and APL’s
iota operator. The SciCL linear sequence generators ~RAMP and ~INDICES define a series of equally spaced values based upon a beginning element (beg), increment (inc), and either an endpoint (end) or element count (cnt).
For example, the Gaussian normal distribution evaluated over a multi-dimensional collection X of unspecified shape can be described using SciCL transformers by:
To construct an N-point, periodic Gaussian window normalized for one-dimensional signal tapering, ~RAMP may be used to evaluate ~GAUSSIAN-DISTRIB over the real interval ± width (measured in units of sigma):
Many SciCL generators such as ~RAMP are implemented as functional objects. SciCL functional objects provide the ability to represent passive data collections (such as a sequence of equally spaced values) as dynamic procedures. When elements of a functional object are accessed as passive data, the referenced elements are computed on demand, rather than retrieved from a passive array.
SciCL provides four additional extensible operator namespaces for defining strongly typed array operations. Number-type specific AG-wise operations are denoted by an alternative single-character prefix identifying the closed CL number types: fixnum (underbar “_”), single-float (period “.”), or double-float (colon “:”). A Matlab-compatible double-complex number type is supported by SciCL operations carrying the (percent “%”) prefix.
SciCL operators are mutually composable with particular efficiency, and may be freely combined with other Common Lisp language elements. The SciCL compiler consolidates functionally-defined selectors such as EVEN, ODD, and JOIN very efficiently, automatically translating applicative (purely “functional”) expressions composed of SciCL primitives into highly-efficient object code.