org.clojars.punit-naik.clj-ml.utils.matrix
absolute
(absolute m)
Calculates the absolute value of each and every element of a 2-D matrix
adjust-rref-indices
(adjust-rref-indices n rref)
Adusts the indices of the RREF of a matrix by looking at the first <x> zeros of the rows
characteristic-equation-parts
(characteristic-equation-parts concatenated-matrix-minus-lambda-i num-rows)
(characteristic-equation-parts concatenated-matrix-minus-lambda-i num-rows positive-part?)
Finds the positive or the negative parts of the characteristic equation
Both the positive and negative parts will be added to form the final eqution
concat-identity-matrix
(concat-identity-matrix matrix)
Concatenates identity matrix of same size to the original matrix to generate [A|I]
concat-matrix-rows
(concat-matrix-rows matrix num-cols)
Concatenates matrix rows with the first `(num-cols - 1)` values of the same row
This helps in finding the characteristic equation of the matrix
covariance
(covariance m)
Calculates the covariance matrix of a 2-D matrix
create-identity-matrix
(create-identity-matrix m)
Same as `org.clojars.punit-naik.clj-ml.utils.matrix/create-matrix`
But this one creates a 2-D identity matrix
create-matrix
(create-matrix {:keys [dimensions seed], :or {seed 10}})
Creates an N-D matrix of `dimenstions` specified in order with random float values in it.
Optional seed (Integer Value) for the random matrix generator can be specified as well.
cross-product
(cross-product row-1-indexed row-2-indexed)
Finds the cross product of two (indexed) rows of a matrix
determinant
(determinant matrix)
Caluclates the determinant of a square matrix by first calculating it's uper triangular matrix
and then multiplying it's diagonal elements together while taking into account the number of row swaps made in the process
dimension
(dimension m)
Returns the dimenston of a 2-D matrix in a vector two elements
eigen-values
(eigen-values matrix)
Gets the eigen values of a matrix from it's characteristic equation
eigen-vector-for-lamba
(eigen-vector-for-lamba matrix lambda)
(eigen-vector-for-lamba matrix lambda already-calculated?)
Finds the eigenvector for a matrix with a particular eigenvalue
eigen-vectors
(eigen-vectors matrix eigen-values)
Finds the Eigenvectors of a matrix by using it's Eigenvalues
equal-dimensions?
(equal-dimensions? m)
Checks if the nested matrices of a matrix have euqal dimensions or not
exponential
(exponential m)
Calculates the exponential of each and every element of a 2-D matrix
get-val
(get-val m index-path)
Get's a specific value from the martix `m` based on the path provided in `index-path`
identity-matrix?
(identity-matrix? m)
Checks if the matrix `m` is a 2-D identity matrix or not
index-matrix-rows
(index-matrix-rows matrix)
This function indexes `matrix`'s rows and returns a map where key is the row number and value is the row itself
invertible?
(invertible? matrix)
Checks if a matrix is invertible or not
lower-triangular-matrix?
(lower-triangular-matrix? m)
matrix-minus-lambda-i
(matrix-minus-lambda-i matrix)
(matrix-minus-lambda-i matrix lambda)
Does A-λI when λ is known as well as unkonwn
matrix-multiply
(matrix-multiply a b)
Multiplies two matrices of MxN and NxP dimensions
Calculates the dot product
matrix?
(matrix? m)
Returns true if a data structure is a valid N-D matrix, else false
mean
(mean m)
Calculates the mean of a 2-D matrix
random-fn
macro
(random-fn n f)
Executes the function `f` repeatedly `n` times
rank
(rank m)
Finds the rank of a mtrix by counting the number of non zero rows
reciprocal
(reciprocal m)
Calculates the reciprocal of each and every element of a 2-D matrix
recursive-row-adjust
(recursive-row-adjust matrix row-index-to-be-processed)
row-adjust
(row-adjust row-1 row-2 n)
using `row-1` to adjust row elements of `row-2` so that their first `n` values are equal to zeros
row-adjust-rref
(row-adjust-rref row-1 row-2 i)
Adjusts the element of `row-1` at index `i` and makes it zero using the elements of `row-2`
sigmoid
(sigmoid m)
(sigmoid m _)
Returns the sigmoid/logistic values of a 2-D matrix
solve-linear-equation-system
(solve-linear-equation-system eq-matrix)
Given a set of linear equations where each equation is represented as:
ax + by + cz + ... = d
In a matrix for like:
[[a1 b1 c1 d1]
[a2 b2 c2 d2]
.
.
[an bn cn dn]]
Tries to find the solution for every unknown, x, y, z in this case
square?
(square? matrix)
Checks if a matrix is quare or not
swap-rows
(swap-rows m i j)
Swaps the rows at the `i`th and `j`th indexes
transpose
(transpose m)
Returns the transpose of a 2-D matrix
triangular-matrix?
(triangular-matrix? m)
upper-triangular-matrix
(upper-triangular-matrix matrix)
Converts any square matrix into an upper-triangular matrix
where all the matrix elements below the diagonal elements are zero
upper-triangular-matrix?
(upper-triangular-matrix? m)
zero-above-below-i-j
(zero-above-below-i-j matrix [i j] num-rows)
Makes all the elements above and below `matrix[i, j]` zero using row transformations