Next: Simple grids and default values, Previous: Reader macro and function <code>grid</code>, Up: Creating a grid
The foreignarray class uses CFFI to allow the use of C arrays as grids.
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 64bit platform:
Element type  Vector class  Matrix class  #m prefix


doublefloat  vectordoublefloat
 matrixdoublefloat
 1 or empty

(complex doublefloat)  vectorcomplexdoublefloat
 matrixcomplexdoublefloat
 2

singlefloat  vectorsinglefloat
 matrixsinglefloat
 3

(complex singlefloat)  vectorcomplexsinglefloat
 matrixcomplexsinglefloat
 4

(signedbyte 8)  vectorsignedbyte8
 matrixsignedbyte8
 7

(unsignedbyte 8)  vectorunsignedbyte8
 matrixunsignedbyte8
 8

(signedbyte 16)  vectorsignedbyte16
 matrixsignedbyte16
 15

(unsignedbyte 16)  vectorunsignedbyte16
 matrixunsignedbyte16
 16

(signedbyte 32)  vectorsignedbyte32
 matrixsignedbyte32
 31

(unsignedbyte 32)  vectorunsignedbyte32
 matrixunsignedbyte32
 32

(signedbyte 64)  vectorsignedbyte64
 matrixsignedbyte64
 63

(unsignedbyte 64)  vectorunsignedbyte64
 matrixunsignedbyte64
 64

A foreign array is especially useful when sending or receiving data from a foreign library. In that case, the generic function grid:foreignpointer
should be called on the foreign array in order to obtain the pointer that the foreign library needs. The identical contents as a CL array is available with the function clarray
under two conditions: the staticvectors system is installed and supported for the CL implementation used, and foreign array was not made with makeforeignarrayfrompointer. If it does exist, this array is the same as the foreign array (not a copy), so for example changing one changes the other:
ANTIKUSER> (defparameter *myfa* (makeforeignarray 'doublefloat :dimensions 3)) ANTIKUSER> *myfa* #m(0.000000000000000d0 1.000000000000000d0 2.000000000000000d0) ANTIKUSER> (clarray *myfa*) #(0.0 1.0 2.0) ANTIKUSER> (setf (grid:aref *myfa* 1) 33.3d0) 33.3 ANTIKUSER> *myfa* #m(0.000000000000000d0 33.300000000000000d0 2.000000000000000d0) ANTIKUSER> (clarray *myfa*) #(0.0 33.3 2.0) ANTIKUSER> (setf (aref (clarray *myfa*) 1) 22.2d0) 22.2 ANTIKUSER> *myfa* #m(0.000000000000000d0 22.200000000000000d0 2.000000000000000d0)