1.20 Matrix Functions: "matrix.rkt"
(require htdp/matrix) |
The experimental teachpack supports matrices and matrix functions. A matrix is just a rectangle of ’objects’. It is displayed as an image, just like the images from Manipulating Images: "image.rkt". Matrices are images and, indeed, scenes in the sense of the Simulations and Animations: "world.rkt".
No educational materials involving matrices exist.
The functions access a matrix in the usual (school-mathematics) manner: row first, column second.
The functions aren’t tuned for efficiency so don’t expect to build programs that process lots of data.
Rectangle A Rectangle (of X) is a non-empty list of lists containing X where all elements of the list are lists of equal (non-zero) length.
procedure
(matrix-rows m) → natural-number/c
m : matrix?
procedure
(matrix-cols m) → natural-number/c
m : matrix?
procedure
(rectangle->matrix r) → matrix?
r : Rectangle
procedure
(matrix->rectangle m) → Rectangle
m : matrix?
procedure
(make-matrix n m l) → matrix?
n : natural-number/c m : natural-number/c l : (Listof X)
NOTE: make-matrix would consume an optional number of entries, if it were like make-vector
procedure
(build-matrix n m f) → matrix?
n : natural-number/c m : natural-number/c
f :
(-> (and/c natural-number/c (</c m)) (and/c natural-number/c (</c n)) any/c)
procedure
(matrix-ref m i j) → any/c
m : matrix? i : (and/c natural-number/c (</c (matrix-rows m))) j : (and/c natural-number/c (</c (matrix-rows m)))
procedure
(matrix-set m i j x) → matrix?
m : matrix? i : (and/c natural-number/c (</c (matrix-rows m))) j : (and/c natural-number/c (</c (matrix-rows m))) x : any/c
procedure
(matrix-render m) → Rectangle
m : matrix?
procedure
(matrix-minor m i j) → matrix?
m : matrix? i : (and/c natural-number/c (</c (matrix-rows m))) j : (and/c natural-number/c (</c (matrix-rows m)))