Skip to content
Snippets Groups Projects
Commit fdb7a09f authored by Liam Healy's avatar Liam Healy
Browse files

Moved array documentation to GSD

parent da5b6d2a
No related branches found
No related tags found
No related merge requests found
...@@ -277,98 +277,11 @@ GSLL has many functions that work on vectors (one-dimensional arrays) ...@@ -277,98 +277,11 @@ GSLL has many functions that work on vectors (one-dimensional arrays)
and matrices (two-dimensional arrays). GSLL supports all array and matrices (two-dimensional arrays). GSLL supports all array
element types that are supported by CFFI, the CL implementation, element types that are supported by CFFI, the CL implementation,
GSL, and the platform. This list is available in the GSL, and the platform. This list is available in the
variable <code>grid:*array-element-types*</code>. On implementations that variable <code>grid:*array-element-types*</code>.
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>
<p> <p>
The <a href="http://repo.or.cz/w/gsd.git">GSD</a> suite provides See the documentation for GSD for more information.
many functions for construction, transformation, and composition of
GSL grid:foreign-arrays. When using grid functions for this purpose, <h3>Passing functions</h3>
the <code>grid:specification</code> will
contain <code>grid:foreign-array</code> as the type; for example,
</p>
<pre>
(grid:make-grid '((grid:foreign-array 3 3) double-float) :initial-element 0)
</pre>
<p>
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.
</p>
<p>
Common Lisp arrays should be created with <code>grid:make-foreign-array</code> or
<code>#m</code>:
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.
<p>
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:
<center>
<table border=5 frame=all cellpadding=4 cellspacing=4 cols=6>
<caption align=top>Element types, vector and matrix
classes</caption>
<thead>
<tr><th><b>Element type</b><td><b>Vector class name</b>
<td><b>Matrix class name</b><td><b>#m prefix</b></thead>
<tbody>
<tr><td>double-float<td>vector-double-float<td>matrix-double-float
<td>1 or empty
<tr><td>(complex double-float)<td>vector-complex-double-float<td>matrix-complex-double-float<td>2
<tr><td>single-float<td>vector-single-float<td>matrix-single-float<td>3
<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
</tbody>
</table>
</center>
<p>
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>
<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>
<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>
<p>If you
use <a href="http://common-lisp.net/project/iterate/">iterate</a>,
there are extensions defined that make it easier to iterate over
grid:foreign-arrays. These are:
<ul>
<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>
</ul>
<p>For example,
<pre>
(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
</pre>
<h3>Passing functions</h3>
<p> <p>
Functions that are passed to GSL functions (known as <i>callbacks</i> Functions that are passed to GSL functions (known as <i>callbacks</i>
in C) are specified with a in C) are specified with a
...@@ -466,7 +379,7 @@ and arrays used internally or for function return. ...@@ -466,7 +379,7 @@ and arrays used internally or for function return.
<!-- Created: Feb 25 2005 --> <!-- Created: Feb 25 2005 -->
<!-- hhmts start --> <!-- hhmts start -->
<small> <small>
Time-stamp: <2010-06-30 21:18:34EDT index.html> Time-stamp: <2010-07-18 22:13:28EDT index.html>
</small> </small>
<!-- hhmts end --> <!-- hhmts end -->
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment