# (chibi math linalg)

Linear algebra and extended array routines.

#### `(array-append axis a . o)`

Returns a new specialized array which is the concatenatation of 1 or more arrays along the `axis` dimension. All arrays must have the same dimension, and all domains must have the same width for each dimension except `axis`.

#### `(array-stack axis a . o)`

Returns a new specialized array which is the joining of 1 or more arrays along a new `axis`. All arrays must have the same domain. The result will be one dimension larger, and `axis` must fit within that dimension.

#### `(array-to-origin array)`

Translates `array` so that it's lower bounds are all zero.Shorthand for array-permute, swapping two dimensions.

#### `(array= a . arrays)`

Returns true iff all arrays have the same domain, and all elements in the same indexes are `=`.

#### `(identity-array n . o)`

Returns the 2-d identity matrix of size `n`.Performs Gaussian elimination and returns the factor to apply to the determinant.

#### `(array-inverse a)`

Returns the inverse of 2-d array `a`, or `#f` if `a` is not invertible.Computes the determinant of 2-d array `a`, mutating `a` in the process.

#### `(determinant a)`

Computes the determinant of 2-d array `a`.

#### `(array-mul a . o)`

Chained matrix multiplication. For a single array, returns that array. For two arrays, performs normal matrix multiplication. For more arrays, determines the optimal associativity and performs the corresponding set of multiplications.

#### `(array-expt a pow)`

Returns `a` multiplied by itself `pow` times.

#### `(array-sum a)`

Returns the sum of all elements in array `a`. Not a norm because it can yield negative results.

#### `(array-1norm a)`

Returns the sum of the absolute values of all elements in array `a`. Aka the L1-norm, taxicab norm, or Manhattan norm.

#### `(array-2norm a)`

Returns the sum of the square of all elements in array `a`. Aka the L2-norm, Euclidean norm, Frobenius norm or square norm.

#### `(array-norm a p)`

Returns the sum of the absolute value of all elements in array `a` raised to the `p` power. Aka the p-norm, this is the generalized form of the above.

#### `(array-inf-norm a)`

Returns the maximum absolute value of all elements in array `a`. Aka the max norm or infinity norm.

#### `(array-convolve a kernel)`

Returns the convolution of array `a` using the given `kernel`.

#### `(pretty-print-array a . opt)`

Nicely formatted printing for arrays of any rank. Ranks higher than 2 are represented as successive 2D drawings. Can generate box drawings with left:, right:, etc. keywords specifying the strings to use. For example, Jacal-style matrix output can be done with: (pretty-print-array a #t 'left: "[" 'right: "]") and a tic-tac-toe board can be printed with (pretty-print-array a #t 'line-char: "|" 'top: "-" 'middle-col: "|" 'center-row: "-")