Next: , Previous: Creating a grid, Up: Creating a grid

4.2.1 Reader macro and function grid

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 mathematical functions, and grid type given by grid:*default-grid-type* (see Types of grids). It optionally takes a numeric argument prefix 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, which is not evaluated. If the list contains ^, the object created will be a matrix and each row is ended with that symbol.

Element type #m prefix
double-float 1 or empty
(complex double-float) 2
single-float 3
(complex single-float) 4
(signed-byte 8) 7
(unsigned-byte 8) 8
(signed-byte 16) 15
(unsigned-byte 16) 16
(signed-byte 32) 31
(unsigned-byte 32) 32
(signed-byte 64) 63
(unsigned-byte 64) 64

The function grid:grid creates a grid of the default type and evaluates its arguments. For example,

     ANTIK-USER> (setf grid:*default-grid-type* 'grid:foreign-array)
     ANTIK-USER> (grid:grid 1.0d0 2.0d0 3.0d0)
     #m(1.000000000000000d0 2.000000000000000d0 3.000000000000000d0)
     ANTIK-USER> (type-of @)

Of course, an ordinary (Common Lisp) array may be created in the usual fashion, with the # reader macro

     #(1.0d0 2.0d0 3.0d0)

or with make-array.