Commit fdb7a09f authored by Liam Healy's avatar Liam Healy
Browse files

Moved array documentation to GSD

parent da5b6d2a
......@@ -277,98 +277,11 @@ GSLL has many functions that work on vectors (one-dimensional arrays)
and matrices (two-dimensional arrays). 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 <code>grid:*array-element-types*</code>. On implementations that
support it (currently only SBCL), the contents are directly available
to the GSL functions without copying between the Lisp area and the C
area of memory.</p>
variable <code>grid:*array-element-types*</code>.
The <a href="">GSD</a> suite provides
many functions for construction, transformation, and composition of
GSL grid:foreign-arrays. When using grid functions for this purpose,
the <code>grid:specification</code> will
contain <code>grid:foreign-array</code> as the type; for example,
(grid:make-grid '((grid:foreign-array 3 3) double-float) :initial-element 0)
will make a 3x3 <code>matrix-double-float</code>.
The functions that the <code>grid</code> system provides such
as <code>transpose</code> as <code>subgrid</code>, are documented
in that collection.
Common Lisp arrays should be created with <code>grid:make-foreign-array</code> or
The #m reader macro in the default form creates a vector or matrix of
element type double-float, which is the most common type needed for
GSL functions. It optionally takes a numeric argument prefix as in
the example above to make an array with a different element type; a
guide to the numeric argument is given below. It should be
followed by a list; this list will be evaluated. If the list
contains <code>^</code>, the object created will be a matrix
and each row is ended with that symbol.
Classes of vectors and matrices are named by appending the element
type as hypenated words to "vector" or "matrix". The following table
shows the classes available on a 64-bit platform:
<table border=5 frame=all cellpadding=4 cellspacing=4 cols=6>
<caption align=top>Element types, vector and matrix
<tr><th><b>Element type</b><td><b>Vector class name</b>
<td><b>Matrix class name</b><td><b>#m prefix</b></thead>
<td>1 or empty
<tr><td>(complex double-float)<td>vector-complex-double-float<td>matrix-complex-double-float<td>2
<tr><td>(complex single-float)<td>vector-complex-single-float<td>matrix-complex-single-float<td>4
<tr><td>(signed-byte 8)<td>vector-signed-byte-8<td>matrix-signed-byte-8<td>7
<tr><td>(unsigned-byte 8)<td>vector-unsigned-byte-8<td>matrix-unsigned-byte-8<td>8
<tr><td>(signed-byte 16)<td>vector-signed-byte-16<td>matrix-signed-byte-16<td>15
<tr><td>(unsigned-byte 16)<td>vector-unsigned-byte-16<td>matrix-unsigned-byte-16<td>16
<tr><td>(signed-byte 32)<td>vector-signed-byte-32<td>matrix-signed-byte-32<td>31
<tr><td>(unsigned-byte 32)<td>vector-unsigned-byte-32<td>matrix-unsigned-byte-32<td>32
<tr><td>(signed-byte 64)<td>vector-signed-byte-64<td>matrix-signed-byte-64<td>63
<tr><td>(unsigned-byte 64)<td>vector-unsigned-byte-64<td>matrix-unsigned-byte-64<td>64
Individual elements are obtained using <code>grid:gref</code> (analogous
to Lisp's <code>aref</code>), and are set
with <code>setf grid:gref</code>. A complete CL array may
be extracted with the function <code>#'cl-array</code>.
<p>Copying grid:foreign-arrays is performed with the function <code>copy</code>.
This works between grid:foreign-arrays, pointers, and CL arrays. It is useful
for functions intended to be passed to GSL functions (for
e.g. solving, minimizing or fitting) that need to set a GSL vector
or matrix, because one can simply copy into the passed-in pointer.
<p>There are two functions provided to extract the dimensions of a
vector or array: <code>dim0</code> and <code>dim1</code>; the latter
is applicable only for matrices.
<p>If you
use <a href="">iterate</a>,
there are extensions defined that make it easier to iterate over
grid:foreign-arrays. These are:
<li><code>matrix-row</code>, <code>matrix-row-index</code></li>
<li><code>matrix-column</code>, <code>matrix-column-index</code></li>
<li><code>vector-element</code>, <code>vector-element-index</code></li>
<li><code>matrix-element</code>, <code>matrix-element-index</code></li>
<p>For example,
(defparameter m1 #m(1 2 3 ^ 0 6 8))
(iter:iter (iter:for e :matrix-element m1) (princ e) (princ " "))
1.0 2.0 3.0 0.0 0.0 6.0 8.0
<h3>Passing functions</h3>
See the documentation for GSD for more information.
<h3>Passing functions</h3>
Functions that are passed to GSL functions (known as <i>callbacks</i>
in C) are specified with a
......@@ -466,7 +379,7 @@ and arrays used internally or for function return.
<!-- Created: Feb 25 2005 -->
<!-- hhmts start -->
Time-stamp: <2010-06-30 21:18:34EDT index.html>
Time-stamp: <2010-07-18 22:13:28EDT index.html>
<!-- hhmts end -->
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment