# (lispkit math matrix)

Library `(lispkit math matrix)`

provides abstractions for representing vectors, matrices and for performing vector and matrix arithmetics. A matrix is a rectangular array of numbers. The library supports common matrix operations such as matrix addition, subtraction, and multiplication. There are operations to create matrices and to manipulate matrix objects. Furthermore, there is support to compute matrix determinants and to transpose and invert matrices. Matrices can be transformed into reduced row echelon form and matrix ranks can be determined.

Symbol representing the `matrix`

type. The `type-for`

procedure of library `(lispkit type)`

returns this symbol for all matrix objects.

Returns a new matrix with *m* rows and *n* columns.

Returns a new matrix consisting of the given rows. Either *rows* is a list of list or numbers, or it is a vector of vectors of numbers. Instead of specifying one *rows* argument, it is also possible to provide the rows *row0*, *row1*, etc. as individual arguments to procedure `matrix`

.

Returns a new identity matrix with `n`

rows and columns.

Returns a copy of *matrix*.

Returns a copy of *matrix* with row *i* and column *j* removed.

Returns a normalized version of *obj*, representing 1*1 matrices and vectors of length 1 as a number, and m*1 and 1*n matrices as a vector.

Returns `#t`

if *obj* is a matrix object, otherwise `#f`

is returned.

Returns `#t`

if *obj* is a vector of numbers.

Returns `#t`

if *matrix* is a zero matrix, i.e. all its elements are zero.

Returns `#t`

if *matrix* is a square matrix, i.e. it has size *n*n*.

Returns `#t`

if *matrix* is an identity matrix, i.e. it has `1`

at the positions *(i, i)* and all other elements are zero.

Returns `#t`

if *matrix* is symmetric, i.e. *matrix* is equal to its transposed matrix.

Returns `#t`

if *matrix* is a matrix of the given dimensions. *m* is the number of rows, *n* is the number of columns.

Returns `#t`

if all matrices *m0*, *m1*, ... are equal to each other, otherwise `#f`

is returned.

Returns the size of *matrix* as a pair whose car is the number of rows and cdr is the number of columns.

Returns the number of rows of *matrix*.

Returns the number of columns of *matrix*.

Returns row *i* of *matrix* as a vector.

Returns column *j* of *matrix* as a vector.

Returns *matrix* as a vector of vectors.

Returns row *i* of *matrix* as a list.

Returns column *j* of *matrix* as a list.

Returns *matrix* as a list of lists.

Swaps columns *j* and *k* of *matrix*.

Swaps rows `i`

and `k`

of `matrix`

.

Returns the *j*-th element of the *i*-th row of *matrix*.

Sets the *j*-th element of the *i*-th row of *matrix* to *x*.

Invokes *f* for every element of *matrix*. *f* is a procedure taking three arguments: the row, the column, and the element at this position. The traversal order is by row, from left to right.

Folds the matrix elements row by row from left to right, invoking *f* with the accumulator, the row, the column and the element at this position.

Returns *matrix* in transposed form.

Sums up *matrix* and all matrices *m0*, ... storing the result in *matrix*.

Subtracts the matrices *m0, ...* from *matrix*, storing the result in *matrix*.

Returns the sum of matrices or vectors *m0, m1, ...*

Returns the difference of matrix or vector *m0* and the matrices or vectors *m1, ...* This procedure also supports vector differences.

Returns the matrix product *m0* * *m1* * *...* or the dot product if *m0*, *m1*, ... are vectors.

Returns a minor of *matrix* by removing row *i* and column *j* and computing the determinant of the remaining matrix. *matrix* needs to be a square matrix.

Returns a minor of *matrix* by removing row *i* and column *j* and computing the determinant of the remaining matrix. The result is negative if the sum of *i* and *j* is odd. *matrix* needs to be a square matrix.

Returns the determinant of *matrix*. *matrix* needs to be a square matrix.

Returns the inverse of *matrix* if it exists. If it does not exist, `#f`

is being returned. *matrix* needs to be a square matrix.

Returns the reduced row echelon matrix of `matrix`

by continuously applying *Gaussian Elimination*.

Returns the rank of *matrix*. The rank of *matrix* is the dimension of the vector space generated by its columns. This corresponds to the maximal number of linearly independent columns of *matrix*.

Returns a multi-line string representation of *matrix*. The elements *x* of *matrix* are converted into a string by invoking `(number->string x len prec noexp)`

.

Last updated