This library is built on top of Liam Healy’s antik/grid library. It contains utilities that are not already present in the “map-grid-utils” and “sequence-grid” libraries.
The library has the following types of routines
- grid io (input only so far)
- iterating functions for grids
- functions that manipulate grids
- functions that reduce grids
Several special variables control the behavior of the routines. The first two are from antik/grid.
*default-grid-type*
- determines the type of grids, native CL,
array
, orforeign-array
*default-element-type*
- determines the float type stored in grids,
single-float
ordouble-float
*default-integer-type*
- determines the integer type stored in grids,
(unsigned-byte 32)
*default-complex-type*
- determines the type of float that makes up
complex variables,
complex
or(complex double-float)
As with grid
, loading the foreign-array
package prior to loading
grid-utils
enables the use of foreign arrays.
This section is meant to provide a functionality overview (which can be improved), not a detailed documentation. For the documentation, consult the source code and the unit tests associated with each function (which can be improved).
There is overlap between some of the functions, and that needs to be cleaned up.
CL-name | Our name | Simple | -if | if-not |
---|---|---|---|---|
count | grid-count | |||
find | find-row | M | M | |
find-col | M | M | ||
position | grid-position | V | V | |
grid-positions | V | V/M | ||
position-nearest | V | |||
positions | V | |||
position-element | V | |||
remove | remove-row | M | M | |
remove-col | M | M | ||
substitute | grid-substitute | M/V |
reverse | reverse-vector | V | ||
copy-seq | ||||
concatenate |
sort | ||||
merge |
subseq |
every | ||||
some | ||||
notany | ||||
notevery |
All operations are non-destructive – the old grid is never modified. There are additional functions such as reverse-vector
These are functions that iterate over a grid, and return a result based on grid contents, or modify a grid element. These are mostly inspired by CL’s sequence functions
Some of these duplicate functionality and may need to be cleaned
grid-position
,grid-position-if
grid-positions
position-nearest
positions
is similar togrid-position-if
but does not accept thekey
argumentposition-element
grid-substitute
remove-row
,remove-row-if
remove-col
,remove-col-if
find-row
,find-row-if
find-col
,find-col-if
reverse-vector
reform
return a matrix filled with vector elementsgrid-coerce
return a new grid with elements coerced to new typegrid-bind
is a macro that binds elements of a grid to variables
There are two types of mapping. In mappings of the first type, all arguments are must be vectors, and the result is built by applying the function to each element in turn.
Mappings of the second type are macros that allow for mappings over a mixture of vectors and scalars, or construct a matrix from a mapping over two vectors.
reduce-vector
reduces a vectorreduce-columns
loops over columns, reducing each. The result is a vectorreduce-rows
loops over rows, reducing each. The result is a vectormap-rows
maps a function over matrix rows, returning the result as a vector
read-grid
reads a grid from stream. It accepts generic or cvs
files - see documentation
The calling and naming convention should follow CL, and not languages like IDL, Matlab, R, etc.
The code is still in early development. Some stuff is missing. The calling and naming of functions is subject to change.
lisp-unit
is used for testing and usage documentation.
I have developed this library on the following two platforms:
- CLISP on cygwin & windows
- SBCL on linux
The development and testing is not always in sync, and development on one platform may introduce bugs on the other that do eventually get fixed.