Liking cljdoc? Tell your friends :D

sicmutils.matrix


*careful-conversion*clj/s

Set this dynamic variable to false to allow s->m to operate on structures for which (* ls ms rs) does NOT yield a numerical value.

Set this dynamic variable to `false` to allow `s->m` to operate on
structures for which `(* ls ms rs)` does NOT yield a numerical value.
sourceraw docstring

->structureclj/s

(->structure m)
(->structure m outer-orientation inner-orientation t?)

Returns a structure generated by converting m into a nested structure with the supplied outer-orientation and inner-orientation.

If t? is true, the columns of m will form the inner tuples. If t? is false, the rows of m will form the inner tuples.

By default, if you supply a single argument (the matrix m), a matrix turns into a single outer ::s/down of inner columns represented as ::up structures.

Returns a structure generated by converting `m` into a nested structure with
the supplied `outer-orientation` and `inner-orientation`.

If `t?` is true, the columns of `m` will form the inner tuples. If `t?` is
false, the rows of `m` will form the inner tuples.

By default, if you supply a single argument (the matrix `m`), a matrix turns
into a single outer `::s/down` of inner columns represented as `::up`
structures.
sourceraw docstring

by-colsclj/s

(by-cols & cols)

Returns a matrix whose columns consist of the supplied sequence of cols. These all must be the same length.

Variadic equivalent to by-cols*.

Returns a matrix whose columns consist of the supplied sequence of `cols`.
These all must be the same length.

Variadic equivalent to [[by-cols*]].
sourceraw docstring

by-cols*clj/s

(by-cols* cols)

Returns a matrix whose columns consist of the supplied sequence of cols. These all must be the same length.

for a variadic equivalent, see by-cols.

Returns a matrix whose columns consist of the supplied sequence of `cols`.
These all must be the same length.

for a variadic equivalent, see [[by-cols]].
sourceraw docstring

by-rowsclj/s

(by-rows & rows)

Returns a matrix whose rows consist of the supplied sequence of rows. These all must be the same length.

Variadic equivalent to by-rows*.

Returns a matrix whose rows consist of the supplied sequence of `rows`. These
all must be the same length.

Variadic equivalent to [[by-rows*]].
sourceraw docstring

by-rows*clj/s

(by-rows* rows)

Returns a matrix whose rows consist of the supplied sequence of rows. These all must be the same length.

for a variadic equivalent, see by-rows.

Returns a matrix whose rows consist of the supplied sequence of `rows`. These
all must be the same length.

for a variadic equivalent, see [[by-rows]].
sourceraw docstring

characteristic-polynomialclj/s

(characteristic-polynomial m x)

Compute the characteristic polynomial of the square matrix m, evaluated at x. Typically x will be a dummy variable, but if you wanted to get the value of the characteristic polynomial at some particular point, you could supply a different expression.

Compute the characteristic polynomial of the square matrix m, evaluated
at x. Typically x will be a dummy variable, but if you wanted to get the
value of the characteristic polynomial at some particular point, you could
supply a different expression.
sourceraw docstring

cofactorsclj/s

(cofactors m)

Returns the matrix of cofactors of the supplied square matrix m.

Returns the matrix of cofactors of the supplied square matrix `m`.
sourceraw docstring

columnclj/s

(column & xs)

Returns a column matrix populated by the supplied xs. Variadic equivalent to column*.

Returns a column matrix populated by the supplied `xs`. Variadic equivalent
to [[column*]].
sourceraw docstring

column*clj/s

(column* xs)

Returns a column matrix populated by the supplied xs. For a variadic equivalent, see column.

Returns a column matrix populated by the supplied `xs`. For a variadic equivalent,
see [[column]].
sourceraw docstring

column-matrix->upclj/s

(column-matrix->up m)

Returns the single column from the supplied column matrix as an up. Errors if some other type is supplied.

Returns the single column from the supplied column matrix as an `up`. Errors if
some other type is supplied.
sourceraw docstring

column-matrix->vectorclj/s

(column-matrix->vector m)

Returns the single column from the supplied column matrix as a vector. Errors if some other type is supplied.

Returns the single column from the supplied column matrix as a vector. Errors
if some other type is supplied.
sourceraw docstring

column?clj/s

(column? m)

Returns true if m is a matrix with a single column (a 'column matrix'), false otherwise.

Returns true if `m` is a matrix with a single column (a 'column matrix'),
false otherwise.
sourceraw docstring

determinantclj/s

(determinant m)

Returns the determinant of the supplied square matrix m. Generic operations are used, so this works on symbolic square matrices.

Returns the determinant of the supplied square matrix `m`. Generic operations
are used, so this works on symbolic square matrices.
sourceraw docstring

diagonalclj/s

(diagonal m)

Returns the diagonal of the supplied matrix m as an up structure. Errors if a type other than a diagonal matrix is supplied.

Returns the diagonal of the supplied matrix `m` as an up structure. Errors if a
type other than a diagonal matrix is supplied.
sourceraw docstring

dimensionclj/s

(dimension m)

Returns the 'dimension', ie, the number of rows & columns, of the supplied square matrix. Errors if some other type is supplied.

Returns the 'dimension', ie, the number of rows & columns, of the supplied
square matrix. Errors if some other type is supplied.
sourceraw docstring

down->row-matrixclj/s

(down->row-matrix v)

Returns a row matrix with the contents of the supplied down structure. Errors if any other type is provided.

Returns a row matrix with the contents of the supplied `down` structure.
Errors if any other type is provided.
sourceraw docstring

fmapclj/s

(fmap f m)

Maps f over the elements of the matrix m returning a new matrix of the same dimensions as m.

Maps `f` over the elements of the matrix `m` returning a new matrix of the same
dimensions as `m`.
sourceraw docstring

fmap-indexedclj/s

(fmap-indexed f m)

Maps f over three arguments:

  • each element of the matrix m
  • its row i
  • its column j

and returns a new matrix of the same dimensions as m.

Maps `f` over three arguments:

- each element of the matrix `m`
- its row `i`
- its column `j`

and returns a new matrix of the same dimensions as `m`. 
sourceraw docstring

generateclj/s

(generate r c f)

Returns a matrix with r rows and c columns, whose entries are generated by the supplied function f.

The entry in the ith row and j-th column is (f i j).

Returns a matrix with `r` rows and `c` columns, whose entries are generated by
the supplied function `f`.

The entry in the `i`th row and `j`-th column is `(f i j)`.
sourceraw docstring

get-inclj/s

(get-in m is)

Like [[clojure.core/get-in]] for matrices, but obeying the scmutils convention: only one index is required to get an unboxed element from a column vector.

NOTE that this is perhaps an unprincipled exception...

Like [[clojure.core/get-in]] for matrices, but obeying the scmutils convention:
only one index is required to get an unboxed element from a column vector.

NOTE that this is perhaps an unprincipled exception...
sourceraw docstring

Iclj/s

(I n)

Return the identity matrix of order n.

Return the identity matrix of order n.
sourceraw docstring

identity-likeclj/s

(identity-like M)

Return an identity matrix whose ones and zeros match the types of the supplied square matrix. Errors if a non-square matrix is supplied.

Return an identity matrix whose ones and zeros match the types of the supplied
square matrix. Errors if a non-square matrix is supplied.
sourceraw docstring

identity?clj/s

(identity? m)

Returns true if the supplied matrix is an identity matrix, false otherwise.

Returns true if the supplied matrix is an identity matrix, false otherwise.
sourceraw docstring

invertclj/s

(invert m)

Returns the inverse of the supplied square matrix m.

Returns the inverse of the supplied square matrix `m`.
sourceraw docstring

literal-matrixclj/s

(literal-matrix sym nrows ncols)

Generates a nrows x ncols matrix of symbolic entries, each prefixed by the supplied symbol sym.

NOTE: The symbols in the returned matrix record their Einstein-notation path into the structure that this matrix represents; a down of up columns. This means that the returned indices embedded in the symbols look flipped, ji vs ij.

For example:

(= (literal-matrix 'x 2 2) (by-rows ['x_0↑0 'x_1↑0] ['x_0↑1 'x_1↑1]))

Generates a `nrows` x `ncols` matrix of symbolic entries, each prefixed by
the supplied symbol `sym`.

NOTE: The symbols in the returned matrix record their Einstein-notation path
into the structure that this matrix represents; a `down` of `up` columns. This
means that the returned indices embedded in the symbols look flipped, `ji` vs
`ij`.

For example:

(= (literal-matrix 'x 2 2)
   (by-rows ['x_0↑0 'x_1↑0]
            ['x_0↑1 'x_1↑1]))
sourceraw docstring

m->sclj/s

(m->s ls m rs)

Convert the matrix m into a structure S, guided by the requirement that (* ls S rs) should be a scalar

Convert the matrix m into a structure S, guided by the requirement that (* ls S rs)
should be a scalar
sourceraw docstring

make-diagonalclj/s

(make-diagonal v)

Returns the diagonal matrix of order (count v) with the elements of v along the diagonal.

Returns the diagonal matrix of order (count v) with the elements of `v` along
the diagonal.
sourceraw docstring

make-zeroclj/s

(make-zero n)
(make-zero m n)

Return a zero-valued matrix of m rows and n columns (nXn if only n is supplied).

Return a zero-valued matrix of `m` rows and `n` columns (`nXn` if only `n` is
supplied).
sourceraw docstring

Matrixcljs

source

matrix->vectorclj/s

(matrix->vector m)

If m is already a vector, acts as identity. Else, returns the matrix as a vector of rows (or throws if neither of these types is passed).

If `m` is already a vector, acts as identity. Else, returns the matrix as a
vector of rows (or throws if neither of these types is passed).
sourceraw docstring

matrix?clj/s

(matrix? m)

Returns true if the supplied m is an instance of Matrix, false otherwise.

Returns true if the supplied `m` is an instance of [[Matrix]], false
otherwise.
sourceraw docstring

nth-colclj/s

(nth-col m n)

Returns the n-th column of the supplied matrix m as an up structure.

Returns the `n`-th column of the supplied matrix `m` as an `up` structure.
sourceraw docstring

nth-rowclj/s

(nth-row m n)

Returns the n-th row of the supplied matrix m as a down structure.

Returns the `n`-th row of the supplied matrix `m` as a `down` structure.
sourceraw docstring

num-colsclj/s

(num-cols m)

Returns the number of columns of the supplied matrix m. Throws if a non-matrix is supplied.

Returns the number of columns of the supplied matrix `m`. Throws if a
non-matrix is supplied.
sourceraw docstring

num-rowsclj/s

(num-rows m)

Returns the number of rows of the supplied matrix m. Throws if a non-matrix is supplied.

Returns the number of rows of the supplied matrix `m`. Throws if a
non-matrix is supplied.
sourceraw docstring

rowclj/s

(row & xs)

Returns a row matrix populated by the supplied xs. Variadic equivalent to row*.

Returns a row matrix populated by the supplied `xs`. Variadic equivalent
to [[row*]].
sourceraw docstring

row*clj/s

(row* xs)

Returns a row matrix populated by the supplied xs. For a variadic equivalent, see row.

Returns a row matrix populated by the supplied `xs`. For a variadic equivalent,
see [[row]].
sourceraw docstring

row-matrix->downclj/s

(row-matrix->down m)

Returns the single row from the supplied row matrix as a down. Errors if some other type is supplied.

Returns the single row from the supplied row matrix as a `down`. Errors if some
other type is supplied.
sourceraw docstring

row-matrix->vectorclj/s

(row-matrix->vector m)

Returns the single row from the supplied row matrix as a vector. Errors if some other type is supplied.

Returns the single row from the supplied row matrix as a vector. Errors if some
other type is supplied.
sourceraw docstring

row?clj/s

(row? m)

Returns true if m is a matrix with a single row (a 'row matrix'), false otherwise.

Returns true if `m` is a matrix with a single row (a 'row matrix'), false
otherwise.
sourceraw docstring

s->mclj/s

(s->m ls ms rs)

Convert the structure ms, which would be a scalar if the (compatible) multiplication (* ls ms rs) were performed, to a matrix.

Convert the structure ms, which would be a scalar if the (compatible)
multiplication
(* ls ms rs) were performed, to a matrix.
sourceraw docstring

s:inverseclj/s

(s:inverse ls ms rs)
source

s:transposeclj/s

(s:transpose ls ms rs)
source

seq->clj/s

(seq-> xs)

Convert a sequence (typically, of function arguments) to an up-structure.

GJS: Any matrix in the argument list wants to be converted to a row of columns

Convert a sequence (typically, of function arguments) to an up-structure.

GJS: Any matrix in the argument list wants to be converted to a row of
columns
sourceraw docstring

someclj/s

(some f m)

Returns true if f is true for some element of the matrix m, false otherwise. (Also works on arbitrary nested sequences.)

Returns true if `f` is true for some element of the matrix `m`, false
otherwise. (Also works on arbitrary nested sequences.)
sourceraw docstring

square-structure->clj/s

(square-structure-> s continue)

Converts the square structure s into a matrix, and calls the supplied continuation continue with

  • the generated matrix.
  • a function which will restore a matrix to a structure with the same inner and outer orientations as s.

Returns the result of the continuation.

Converts the square structure `s` into a matrix, and calls the supplied
continuation `continue` with

- the generated matrix.
- a function which will restore a matrix to a structure with the same inner
  and outer orientations as s.

Returns the result of the continuation.
sourceraw docstring

square-structure-operationclj/s

(square-structure-operation s f)

Applies matrix operation f to square structure s and returns a structure of the same type as the supplied structure.

Applies matrix operation `f` to square structure `s` and returns a structure of
the same type as the supplied structure.
sourceraw docstring

square?clj/s

(square? m)

Returns true if m is a square matrix, false otherwise.

Returns true if `m` is a square matrix, false otherwise.
sourceraw docstring

submatrixclj/s

(submatrix m lowrow hirow lowcol hicol)

Returns the submatrix of m generated by taking

  • rows from lowrow -> hirow,
  • columns from lowcol -> hicol
Returns the submatrix of `m` generated by taking

- rows from `lowrow` -> `hirow`,
- columns from `lowcol` -> `hicol`
sourceraw docstring

traceclj/s

(trace m)

Returns the trace (the sum of diagonal elements) of the square matrix m. Generic operations are used, so this works on symbolic square matrices.

Returns the trace (the sum of diagonal elements) of the square matrix `m`.
Generic operations are used, so this works on symbolic square matrices.
sourceraw docstring

transposeclj/s

(transpose m)

Returns the transpose of the matrix m. The transpose is the original matrix, with rows and columns swapped.

Returns the transpose of the matrix `m`. The transpose is the original matrix,
with rows and columns swapped.
sourceraw docstring

up->column-matrixclj/s

(up->column-matrix v)

Returns a column matrix with the contents of the supplied up structure. Errors if any other type is provided.

Returns a column matrix with the contents of the supplied `up` structure.
Errors if any other type is provided.
sourceraw docstring

with-substituted-rowclj/s

(with-substituted-row m i v)

Returns a new matrix of identical shape to m, with the vector v substituted for the ith row.

Returns a new matrix of identical shape to `m`, with the vector `v` substituted
for the `i`th row.
sourceraw docstring

withoutclj/s

(without m i j)

Returns the matrix formed by deleting the i-th row and j-th column of the given matrix m.

Returns the matrix formed by deleting the `i`-th row and `j`-th column of the
given matrix `m`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close