(=== apache-m)(=== apache-m1 apache-m2)(=== apache-m1 apache-m2 & apache-ms)Apache Commons matrix equality that works with NaN.
Apache Commons matrix equality that works with NaN.
(add apache-m)(add apache-m1 apache-m2)(add apache-m1 apache-m2 & apache-ms)Apache Commons matrix addition.
Apache Commons matrix addition.
(apache-matrix m)Returns a matrix using the Apache Commons matrix implementation.
Returns a matrix using the Apache Commons matrix implementation.
(apache-matrix->matrix apache-m)Converts an Apache Commons matrix into a matrix.
Converts an Apache Commons matrix into a matrix.
(apache-matrix-finite? x)Returns true if an Apache Commons matrix without infinite numbers.
Returns true if an Apache Commons matrix without infinite numbers.
(apache-matrix? x)Returns true if an Apache Commons matrix.
Returns true if an Apache Commons matrix.
(assoc-diagonal! apache-m numbers)Sets a diagonal in an Apache Commons matrix using the specified numbers.
Sets a diagonal in an Apache Commons matrix using the specified numbers.
(assoc-entry! apache-m row column number)Sets an entry in an Apache Commons matrix.
Sets an entry in an Apache Commons matrix.
(cholesky-decomposition positive-definite-apache-m)Computes the Cholesky decomposition of a positive definite Apache Commons
matrix. Returns a map of two Apache Commons matrices ::cholesky-L and
::choleskyLT. This is the Cholesky square root of a matrix, 'L' and 'LT'
such that positive-definite-apache-m = L × LT. Note that
positive-definite-apache-m must be positive semidefinite for this to exist,
but cholesky-decomposition requires strict positivity.
Computes the Cholesky decomposition of a positive definite Apache Commons matrix. Returns a map of two Apache Commons matrices `::cholesky-L` and `::choleskyLT`. This is the Cholesky square root of a matrix, 'L' and 'LT' such that `positive-definite-apache-m` = L × LT. Note that `positive-definite-apache-m` must be positive semidefinite for this to exist, but [[cholesky-decomposition]] requires strict positivity.
(columns apache-m)Returns the number of columns.
Returns the number of columns.
(concat-columns)(concat-columns apache-m)(concat-columns apache-m & apache-ms)Appends columns from all the Apache Common matrices after the first to the first. Each matrix's row count must be the same or will return nil.
Appends columns from all the Apache Common matrices after the first to the first. Each matrix's row count must be the same or will return nil.
(concat-rows)(concat-rows apache-m)(concat-rows apache-m & apache-ms)Appends rows from all the Apache Common matrices after the first to the first. Each matrix's column count must be the same or will return nil.
Appends rows from all the Apache Common matrices after the first to the first. Each matrix's column count must be the same or will return nil.
(condition singular-values-apache-matrix)The singular-values-apache-matrix is the diagonal matrix of
::singular-values from sv-decomposition. Returns the norm2 condition
number, which is the maximum element value from the
singular-values-apache-matrix divided by the minimum element value.
The `singular-values-apache-matrix` is the diagonal matrix of `::singular-values` from [[sv-decomposition]]. Returns the norm2 condition number, which is the maximum element value from the `singular-values-apache-matrix` divided by the minimum element value.
(correlation-apache-matrix->covariance-apache-matrix correlation-apache-matrix
variances)Returns Covariance Apache Commons matrix from a Correlation Apache Commons matrix.
Returns Covariance Apache Commons matrix from a Correlation Apache Commons matrix.
(correlation-apache-matrix-by-squaring square-apache-m-finite)Returns a finite Correlation Apache Commons matrix by first squaring
square-apache-m-finite.
Returns a finite Correlation Apache Commons matrix by first squaring `square-apache-m-finite`.
(correlation-apache-matrix? x accu)Returns true if a finite positive definite Apache Commons matrix with a unit
diagonal. Larger accu creates more false negatives and less false
positives.
Returns true if a finite positive definite Apache Commons matrix with a unit diagonal. Larger `accu` creates more false negatives and less false positives.
(covariance-apache-matrix->correlation-apache-matrix covariance-apache-matrix)Returns Correlation Apache Commons matrix from a Covariance Apache Commons matrix.
Returns Correlation Apache Commons matrix from a Covariance Apache Commons matrix.
(diagonal apache-m)(diagonal apache-m k)Returns the specified diagonal of an Apache Commons matrix as a vector. If 'k'>0, returns a diagonal above the main diagonal. If 'k'<0, returns a diagonal below the main diagonal. Works on both square and rectangular matrices.
Returns the specified diagonal of an Apache Commons matrix as a vector. If 'k'>0, returns a diagonal above the main diagonal. If 'k'<0, returns a diagonal below the main diagonal. Works on both square and rectangular matrices.
(diagonal-apache-matrix? x)Returns true if a diagonal matrix (the entries outside the main diagonal are all zero).
Returns true if a diagonal matrix (the entries outside the main diagonal are all zero).
(eigen-decomposition square-apache-m-finite)Computes the Eigendecomposition of a diagonalisable matrix.
Returns a map containing:
::eigenvectorsT -- square Apache Commons matrix with each column containing
the eigenvectors
::eigenvalues-matrix -- Apache Commons matrix whose diagonal elements are
the eigenvalues, if they exist
::eigenvalues -- vector of real parts of eigenvalues (nil if imaginary
parts exist)
::eigenvectors -- square Apache Commons matrix with each row containing the
eigenvectors
square-apache-m-finite = eigenvectorsT × eigenvalues-matrix ×
(inverse eigenvectorsT).
Computes the Eigendecomposition of a diagonalisable matrix.
Returns a map containing:
`::eigenvectorsT` -- square Apache Commons matrix with each column containing
the eigenvectors
`::eigenvalues-matrix` -- Apache Commons matrix whose diagonal elements are
the eigenvalues, if they exist
`::eigenvalues` -- vector of real parts of eigenvalues (nil if imaginary
parts exist)
`::eigenvectors` -- square Apache Commons matrix with each row containing the
eigenvectors
`square-apache-m-finite` = `eigenvectorsT` × `eigenvalues-matrix` ×
(inverse `eigenvectorsT`).(empty-apache-matrix? x)Returns true if an empty Apache Commons matrix.
Returns true if an empty Apache Commons matrix.
(get-column apache-m column)Gets a column of an Apache Commons matrix, as a vector.
Gets a `column` of an Apache Commons matrix, as a vector.
(get-entry apache-m row column)Returns the specified Apache Commons matrix element.
Returns the specified Apache Commons matrix element.
(get-row apache-m row)Gets a row of an Apache Commons matrix, as a vector.
Gets a `row` of an Apache Commons matrix, as a vector.
(get-slices-as-matrix apache-m
{:keys [:provisdom.math.matrix/row-indices
:provisdom.math.matrix/column-indices
:provisdom.math.matrix/exception-row-indices
:provisdom.math.matrix/exception-column-indices]})Performs a slice on the Apache Commons matrix given by the options.
Options:
::mx/row-indices returns all rows by default, can pass a row index or
sequence of row indices
::mx/column-indices returns all columns by default, can pass a column
index or sequence of column indices
::mx/exception-row-indices can pass a row index or sequence of row indices
to exclude
::mx/exception-column-indices can pass a column index or sequence of
column indices to exclude.
Exceptions override inclusions. Can be used to permute matrix through index
sequence ordering.
Performs a slice on the Apache Commons matrix given by the options.
Options:
`::mx/row-indices` returns all rows by default, can pass a row index or
sequence of row indices
`::mx/column-indices` returns all columns by default, can pass a column
index or sequence of column indices
`::mx/exception-row-indices` can pass a row index or sequence of row indices
to exclude
`::mx/exception-column-indices` can pass a column index or sequence of
column indices to exclude.
Exceptions override inclusions. Can be used to permute matrix through index
sequence ordering.(inverse square-apache-m)Returns the inverse of a square Apache Commons matrix. Uses QR Decomposition by default but will use other methods depending on matrix structure.
Returns the inverse of a square Apache Commons matrix. Uses QR Decomposition by default but will use other methods depending on matrix structure.
(lower-triangular-apache-matrix? x)Returns true if a lower triangular matrix (the entries above the main diagonal are all zero).
Returns true if a lower triangular matrix (the entries above the main diagonal are all zero).
(lu-decomposition-with-determinant square-apache-m)Returns a map containing:
::L -- the lower triangular factor Apache Commons matrix
::U -- the upper triangular factor Apache Commons matrix
::LU-permutation -- the permutation Apache Commons matrix
::determinant -- the determinant.
Returns a map containing: `::L` -- the lower triangular factor Apache Commons matrix `::U` -- the upper triangular factor Apache Commons matrix `::LU-permutation` -- the permutation Apache Commons matrix `::determinant` -- the determinant.
(lu-decomposition-with-determinant-and-inverse square-apache-m)Returns a map containing
::L -- the lower triangular factor Apache Commons matrix
::U -- the upper triangular factor Apache Commons matrix
::LU-permutation -- the permutation Apache Commons matrix
::determinant -- the determinant
::inverse -- the inverse Apache Commons matrix.
Returns a map containing `::L` -- the lower triangular factor Apache Commons matrix `::U` -- the upper triangular factor Apache Commons matrix `::LU-permutation` -- the permutation Apache Commons matrix `::determinant` -- the determinant `::inverse` -- the inverse Apache Commons matrix.
(matrix-partition apache-m first-bottom-row first-right-column)Returns a map containing the four sub-matrices labeled ::top-left,
::bottom-left, ::top-right, and ::bottom-right.
first-bottom-row is the bottom of where the slice will occur.
first-right-column is the right edge of where the slice will occur.
Returns a map containing the four sub-matrices labeled `::top-left`, `::bottom-left`, `::top-right`, and `::bottom-right`. `first-bottom-row` is the bottom of where the slice will occur. `first-right-column` is the right edge of where the slice will occur.
(mx* apache-m)(mx* apache-m1 apache-m2)(mx* apache-m1 apache-m2 & apache-ms)Apache Commons matrix multiplication. Number of columns of the first matrix must match the number of rows of the second matrix.
Apache Commons matrix multiplication. Number of columns of the first matrix must match the number of rows of the second matrix.
(positive-definite-apache-matrix-finite-by-squaring square-apache-m-finite)Returns a finite positive definite Apache Commons matrix squaring it. Will tweak original matrix if necessary to ensure positive definite.
Returns a finite positive definite Apache Commons matrix squaring it. Will tweak original matrix if necessary to ensure positive definite.
(positive-definite-apache-matrix-finite? x accu)Returns true if a finite positive definite Apache matrix. Larger accu
creates more false negatives and less false positives.
Returns true if a finite positive definite Apache matrix. Larger `accu` creates more false negatives and less false positives.
(positive-semidefinite-apache-matrix-finite-by-squaring square-apache-m-finite)Returns a finite positive semidefinite Apache Commons matrix by first
squaring square-apache-m-finite.
Returns a finite positive semidefinite Apache Commons matrix by first squaring `square-apache-m-finite`.
(positive-semidefinite-apache-matrix-finite? x accu)Returns true if a finite positive-semidefinite Apache matrix. Larger accu
creates more false positives and less false negatives.
Returns true if a finite positive-semidefinite Apache matrix. Larger `accu` creates more false positives and less false negatives.
(qr-decomposition apache-m)Computes the QR decomposition of an Apache Commons matrix. Returns a map
containing Apache Commons matrices Q and R:
::Q -- orthogonal factors
::R -- the upper triangular factors (not necessarily an upper triangular
Apache Commons matrix).
Computes the QR decomposition of an Apache Commons matrix. Returns a map
containing Apache Commons matrices Q and R:
`::Q` -- orthogonal factors
`::R` -- the upper triangular factors (not necessarily an upper triangular
Apache Commons matrix).(qr-decomposition-with-linear-least-squares apache-m1 apache-m2)Returns a map containing:
::Q -- orthogonal factors of apache-m1
::R -- the upper triangular factors of apache-m2
::linear-least-squares -- Apache Commons matrix with linear least squares
solution.
Returns a map containing: `::Q` -- orthogonal factors of `apache-m1` `::R` -- the upper triangular factors of `apache-m2` `::linear-least-squares` -- Apache Commons matrix with linear least squares solution.
(qr-decomposition-with-linear-least-squares-and-error-matrix apache-m1
apache-m2)Returns a map containing:
::Q -- orthogonal factors of apache-m1
::R -- the upper triangular factors of apache-m2 (not necessarily
square)
::LLS-solution -- Apache Commons matrix with linear least squares solution
::error -- Apache Commons matrix of errors.
Returns a map containing: `::Q` -- orthogonal factors of `apache-m1` `::R` -- the upper triangular factors of `apache-m2` (not necessarily square) `::LLS-solution` -- Apache Commons matrix with linear least squares solution `::error` -- Apache Commons matrix of errors.
(rank-revealing-qr-decomposition apache-m accu)Calculates the rank-revealing QR-decomposition of a matrix, with column
pivoting. The rank-revealing QR-decomposition of apache-m consists of three
matrices Q, R, and RRQR-permutation such that:
apache-m × permutation = Q × R. Q is orthogonal (QT × Q = I), and
R is upper triangular. If apache-m is m × n, Q is m × m, R is m × n,
and RRQR-permutation is n × n. QR decomposition with column pivoting
produces a rank-revealing QR decomposition. This class computes the
decomposition using Householder reflectors. Returns a map containing:
::Q -- orthogonal factors
::R -- the upper triangular factors
::RRQR-permutation -- Permutation Matrix
::rank -- the rank.
Calculates the rank-revealing QR-decomposition of a matrix, with column
pivoting. The rank-revealing QR-decomposition of `apache-m` consists of three
matrices `Q`, `R`, and `RRQR-permutation` such that:
`apache-m` × `permutation` = `Q` × `R`. `Q` is orthogonal (QT × `Q` = I), and
`R` is upper triangular. If `apache-m` is m × n, `Q` is m × m, `R` is m × n,
and `RRQR-permutation` is n × n. QR decomposition with column pivoting
produces a rank-revealing QR decomposition. This class computes the
decomposition using Householder reflectors. Returns a map containing:
`::Q` -- orthogonal factors
`::R` -- the upper triangular factors
`::RRQR-permutation` -- Permutation Matrix
`::rank` -- the rank.(rectangular-cholesky-decomposition positive-semidefinite-apache-m accu)Calculates the rectangular Cholesky decomposition of a positive semidefinite
Apache Commons matrix. The rectangular Cholesky decomposition of a real
positive-semidefinite-apache-m consists of a rectangular-root matrix with
the same number of rows such that positive-semidefinite-apache-m is almost
equal to rectangular-root × (transpose rectangular-root), depending on a
user-defined tolerance. In a sense, this is the square root of
positive-semidefinite-apache-m. The difference with respect to the regular
CholeskyDecomposition is that rows/columns may be permuted (hence the
rectangular shape instead of the traditional triangular shape) and there is a
threshold to ignore small diagonal elements. This is used for example to
generate correlated random n-dimensions vectors in a p-dimension subspace
(p < n). In other words, it allows generating random vectors from a covariance
matrix that is only positive semidefinite, and not positive definite.
accu - Diagonal elements threshold under which columns are considered to be
dependent on previous ones and are discarded.
Returns a map containing:
::rectangular-root -- rectangular root Apache Commons matrix
::rank -- rank is the number of independent rows of original matrix, and
the number of columns of rectangular-root matrix.
Calculates the rectangular Cholesky decomposition of a positive semidefinite
Apache Commons matrix. The rectangular Cholesky decomposition of a real
`positive-semidefinite-apache-m` consists of a `rectangular-root` matrix with
the same number of rows such that `positive-semidefinite-apache-m` is almost
equal to `rectangular-root` × (transpose `rectangular-root`), depending on a
user-defined tolerance. In a sense, this is the square root of
`positive-semidefinite-apache-m`. The difference with respect to the regular
CholeskyDecomposition is that rows/columns may be permuted (hence the
rectangular shape instead of the traditional triangular shape) and there is a
threshold to ignore small diagonal elements. This is used for example to
generate correlated random n-dimensions vectors in a p-dimension subspace
(p < n). In other words, it allows generating random vectors from a covariance
matrix that is only positive semidefinite, and not positive definite.
`accu` - Diagonal elements threshold under which columns are considered to be
dependent on previous ones and are discarded.
Returns a map containing:
`::rectangular-root` -- rectangular root Apache Commons matrix
`::rank` -- rank is the number of independent rows of original matrix, and
the number of columns of `rectangular-root` matrix.(rnd-correlation-apache-matrix! size)Returns a correlation Apache Commons matrix from a covariance matrix
with a random spectrum. The orthogonal matrices are generated by using
2 * size composed Householder reflections.
Alternative #1: Sample Covariance from the Inverse-Wishart Distribution.
Alternative #2: Use correlation-apache-matrix-by-squaring with a
random square matrix.
Returns a correlation Apache Commons matrix from a covariance matrix with a random spectrum. The orthogonal matrices are generated by using 2 * `size` composed Householder reflections. Alternative #1: Sample Covariance from the Inverse-Wishart Distribution. Alternative #2: Use [[correlation-apache-matrix-by-squaring]] with a random square matrix.
(rnd-positive-definite-apache-matrix-finite! size)Returns a finite positive definite Apache Commons matrix with a random
spectrum. The orthogonal matrices are generated by using 2 × size composed
Householder reflections.
Alternative #1: Sample from the Inverse-Wishart Distribution.
Alternative #2: Use positive-definite-apache-matrix-finite-by-squaring
with a random square matrix.
Returns a finite positive definite Apache Commons matrix with a random spectrum. The orthogonal matrices are generated by using 2 × `size` composed Householder reflections. Alternative #1: Sample from the Inverse-Wishart Distribution. Alternative #2: Use [[positive-definite-apache-matrix-finite-by-squaring]] with a random square matrix.
(some-kv pred apache-m)(some-kv pred
apache-m
{:keys [:provisdom.math.matrix/by-row?] :or {by-row? true}})Returns the first logical true value of (pred row column number) for any
number in Apache Commons matrix, else nil.
Options: ::mx/by-row? (default: true).
Returns the first logical true value of (pred row column number) for any number in Apache Commons matrix, else nil. Options: `::mx/by-row?` (default: true).
(square-apache-matrix? x)Returns true if a square Apache Commons matrix (i.e., same number of rows and columns).
Returns true if a square Apache Commons matrix (i.e., same number of rows and columns).
(subtract apache-m)(subtract apache-m1 apache-m2)(subtract apache-m1 apache-m2 & apache-ms)Apache Commons matrix subtraction.
Apache Commons matrix subtraction.
(sv-decomposition apache-m)Calculates the compact Singular Value Decomposition of an Apache Commons
matrix. The Singular Value Decomposition of apache-m is a set of three
matrices: svd-left, singular-values, and svd-right such that:
apache-m = svd-left × singular-values × svd-right.
Let apache-m be a m × n matrix, then svd-left is a m × p orthogonal
matrix of the left singular vectors, singular-values is a p × p diagonal
matrix of singular values with positive or nil elements, and are ordered from
largest to smallest. svd-right is a p × n orthogonal matrix of the right
singular vectors where p = min(m,n). Note that:
Identity Matrix = (transpose svd-left) × svd-left =
svd-right × (transpose svd-right).
Returns a map containing:
::svd-left -- Apache Commons matrix of left singular vectors
::singular-values -- diagonal Apache Commons matrix
::svd-right -- transpose of Apache Commons matrix of right singular
vectors
::rank -- rank.
Calculates the compact Singular Value Decomposition of an Apache Commons
matrix. The Singular Value Decomposition of `apache-m` is a set of three
matrices: `svd-left`, `singular-values`, and `svd-right` such that:
`apache-m` = `svd-left` × `singular-values` × `svd-right`.
Let `apache-m` be a m × n matrix, then `svd-left` is a m × p orthogonal
matrix of the left singular vectors, `singular-values` is a p × p diagonal
matrix of singular values with positive or nil elements, and are ordered from
largest to smallest. `svd-right` is a p × n orthogonal matrix of the right
singular vectors where p = min(m,n). Note that:
Identity Matrix = (transpose `svd-left`) × `svd-left` =
`svd-right` × (transpose `svd-right`).
Returns a map containing:
`::svd-left` -- Apache Commons matrix of left singular vectors
`::singular-values` -- diagonal Apache Commons matrix
`::svd-right` -- transpose of Apache Commons matrix of right singular
vectors
`::rank` -- rank.(symmetric-apache-matrix-by-averaging! square-apache-m)Updates symmetric Apache Commons matrix where each element above or below the diagonal is equal to the average of the corresponding numbers. This is useful to help with rounding errors.
Updates symmetric Apache Commons matrix where each element above or below the diagonal is equal to the average of the corresponding numbers. This is useful to help with rounding errors.
(symmetric-apache-matrix? x)Returns true is a symmetric Apache Commons matrix.
Returns true is a symmetric Apache Commons matrix.
(trace square-apache-m)Calculates the trace of a square Apache Commons matrix (sum of elements on main diagonal).
Calculates the trace of a square Apache Commons matrix (sum of elements on main diagonal).
(transpose apache-m)Transposes an Apache Commons matrix by swapping rows and columns, returning a new Apache Commons matrix.
Transposes an Apache Commons matrix by swapping rows and columns, returning a new Apache Commons matrix.
(upper-triangular-apache-matrix? x)Returns true if an upper triangular matrix (the entries below the main diagonal are all zero).
Returns true if an upper triangular matrix (the entries below the main diagonal are all zero).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |