#### 7.2Types, Predicates and Accessors

 syntax(Matrix A)
Equivalent to (Array A), but used for values M for which (matrix? M) is #t.

 procedure(matrix? arr) → Boolean arr : (Array A)
Returns #t when arr is a matrix: a nonempty array with exactly two axes.

Examples:

 > (matrix? (array 10)) - : Boolean #f > (matrix? (array #[1 2 3])) - : Boolean #f > (matrix? (make-array #(5 0) 0)) - : Boolean #f > (matrix? (array #[#[1 0] #[0 1]])) - : Boolean #t

 procedure(row-matrix? arr) → Boolean arr : (Array A)
Returns #t when arr is a row matrix: a matrix with exactly one row.

 procedure(col-matrix? arr) → Boolean arr : (Array A)
Returns #t when arr is a column matrix: a matrix with exactly one column.

 procedure(square-matrix? arr) → Boolean arr : (Array A)
Returns #t when arr is a matrix with the same number of rows and columns.

 procedure M : (Matrix A)
Returns M’s row and column count, respectively. Raises an error if (matrix? M) is #f.

Examples:

> (matrix-shape (row-matrix [1 2 3]))

- : (Values Integer Integer) [generalized from (Values Index Index)]

 1 3
> (matrix-shape (col-matrix [1 2 3]))

- : (Values Integer Integer) [generalized from (Values Index Index)]

 3 1
> (matrix-shape (identity-matrix 3))

- : (Values Integer Integer) [generalized from (Values Index Index)]

 3 3

 procedure M : (Matrix A)
Returns the number of rows in M, or the first value of (matrix-shape M).

 procedure M : (Matrix A)
Returns the number of columns in M, or the second value of (matrix-shape M).

 procedure M : (Matrix A)
Returns the number of rows/columns in M. Raises an error if (square-matrix? M) is #f.

Examples:

 > (square-matrix-size (identity-matrix 3)) - : Integer [generalized from Index] 3 > (square-matrix-size (row-matrix [1 2 3])) square-matrix-size: contract violation expected: square-matrix? given: (array #[#[1 2 3]])