Class CommonOps_DSCC
- java.lang.Object
-
- org.ejml.sparse.csc.CommonOps_DSCC
-
public class CommonOps_DSCC extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CommonOps_DSCC()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidadd(double alpha, org.ejml.data.DMatrixSparseCSC A, double beta, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Performs matrix addition:
C = αA + βBstatic voidchangeSign(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B)B = -A.static booleancheckDuplicateElements(org.ejml.data.DMatrixSparseCSC A)Checks for duplicate elements.static booleancheckIndicesSorted(org.ejml.data.DMatrixSparseCSC A)Checks to see if row indicies are sorted into ascending order.static booleancheckSortedFlag(org.ejml.data.DMatrixSparseCSC A)static booleancheckStructure(org.ejml.data.DMatrixSparseCSC A)static voidcolumnMaxAbs(org.ejml.data.DMatrixSparseCSC A, double[] values)Finds the maximum abs in each column of A and stores it into valuesstatic org.ejml.data.DMatrixSparseCSCconcatColumns(org.ejml.data.DMatrixSparseCSC left, org.ejml.data.DMatrixSparseCSC right, org.ejml.data.DMatrixSparseCSC out)Concats two matrices along their columns (horizontal).static org.ejml.data.DMatrixSparseCSCconcatRows(org.ejml.data.DMatrixSparseCSC top, org.ejml.data.DMatrixSparseCSC bottom, org.ejml.data.DMatrixSparseCSC out)Concats two matrices along their rows (vertical).static doubledet(org.ejml.data.DMatrixSparseCSC A)Returns the determinant of the matrix.static org.ejml.data.DMatrixSparseCSCdiag(double... values)Returns a diagonal matrix with the specified diagonal elements.static org.ejml.data.DMatrixSparseCSCdiag(org.ejml.data.DMatrixSparseCSC A, double[] values, int offset, int length)Creates a diagonal matrix from an array.static voiddivide(double scalar, org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B)B = scalar/A.static voiddivide(org.ejml.data.DMatrixSparseCSC A, double scalar, org.ejml.data.DMatrixSparseCSC B)B = A/scalar.static voiddivideColumns(org.ejml.data.DMatrixSparseCSC A, double[] values, int offset)Divides all elements of column 'i' by values[i].static voiddivideRows(double[] diag, int offset, org.ejml.data.DMatrixSparseCSC A)Divides all elements of row 'i' by value[i].static voiddivideRowsCols(double[] diagA, int offsetA, org.ejml.data.DMatrixSparseCSC B, double[] diagC, int offsetC)Equivalent to multiplying a matrix B by the inverse of two diagonal matrices.static doubledotInnerColumns(org.ejml.data.DMatrixSparseCSC A, int colA, org.ejml.data.DMatrixSparseCSC B, int colB, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Computes the inner product of two column vectors taken from the input matrices.static doubleelementMax(org.ejml.data.DMatrixSparseCSC A)Returns the value of the element with the largest valuestatic doubleelementMaxAbs(org.ejml.data.DMatrixSparseCSC A)Returns the value of the element with the largest abs()static doubleelementMin(org.ejml.data.DMatrixSparseCSC A)Returns the value of the element with the minimum valuestatic doubleelementMinAbs(org.ejml.data.DMatrixSparseCSC A)Returns the value of the element with the smallest abs()static voidelementMult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Performs an element-wise multiplication.
C[i,j] = A[i,j]*B[i,j]
All matrices must have the same shape.static doubleelementSum(org.ejml.data.DMatrixSparseCSC A)Sum of all elementsstatic voidextract(org.ejml.data.DMatrixSparseCSC src, int srcY0, int srcY1, int srcX0, int srcX1, org.ejml.data.DMatrixSparseCSC dst, int dstY0, int dstX0)Extracts a submatrix from 'src' and inserts it in a submatrix in 'dst'.static org.ejml.data.DMatrixSparseCSCextractColumn(org.ejml.data.DMatrixSparseCSC A, int column, org.ejml.data.DMatrixSparseCSC out)Extracts a column from A and stores it into out.static voidextractDiag(org.ejml.data.DMatrixSparseCSC src, org.ejml.data.DMatrixRMaj dst)Extracts the diagonal elements 'src' write it to the 'dst' vector.static voidextractDiag(org.ejml.data.DMatrixSparseCSC src, org.ejml.data.DMatrixSparseCSC dst)Extracts the diagonal elements 'src' write it to the 'dst' vector.static org.ejml.data.DMatrixSparseCSCextractRows(org.ejml.data.DMatrixSparseCSC A, int row0, int row1, org.ejml.data.DMatrixSparseCSC out)Creates a submatrix by extracting the specified rows from A.static voidfill(org.ejml.data.DMatrixSparseCSC A, double value)Sets every element in the matrix to the specified value.static org.ejml.data.DMatrixSparseCSCidentity(int length)static org.ejml.data.DMatrixSparseCSCidentity(int numRows, int numCols)static voidinnerProductLower(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Computes the inner product of A times A and stores the results in B.static booleaninvert(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj inverse)Performs a matrix inversion operation that does not modify the original and stores the results in another matrix.static org.ejml.data.DMatrixRMajmaxCols(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixRMaj output)Computes the maximums of each column in the input matrix and returns the results in a vector:
bj = max(i=1:m ; aij)static org.ejml.data.DMatrixRMajmaxRows(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixRMaj output, org.ejml.data.IGrowArray gw)Computes the maximum of each row in the input matrix and returns the results in a vector:
bj = max(i=1:n ; aji)static org.ejml.data.DMatrixRMajminCols(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixRMaj output)Computes the minimum of each column in the input matrix and returns the results in a vector:
bj = min(i=1:m ; aij)static org.ejml.data.DMatrixRMajminRows(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixRMaj output, org.ejml.data.IGrowArray gw)Computes the minimum of each row in the input matrix and returns the results in a vector:
bj = min(i=1:n ; aji)static voidmult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication.static voidmult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C)static voidmult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Performs matrix multiplication.static voidmultAdd(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + A*Bstatic voidmultAddTransA(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + AT*Bstatic voidmultAddTransAB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + AT*BTstatic voidmultAddTransB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + A*BTstatic voidmultColumns(org.ejml.data.DMatrixSparseCSC A, double[] values, int offset)Multiply all elements of column 'i' by value[i].static voidmultRows(double[] diag, int offset, org.ejml.data.DMatrixSparseCSC A)Multiply all elements of row 'i' by value[i].static voidmultRowsCols(double[] diagA, int offsetA, org.ejml.data.DMatrixSparseCSC B, double[] diagC, int offsetC)Equivalent to multiplying a matrix B by two diagonal matrices.static voidmultTransA(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication.static voidmultTransA(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)static voidmultTransAB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication.static voidmultTransB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication.static voidmultTransB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Performs matrix multiplication.static int[]permutationInverse(int[] original, int length)static voidpermutationInverse(int[] original, int[] inverse, int length)Computes the inverse permutation vectorstatic org.ejml.data.DMatrixSparseCSCpermutationMatrix(int[] p, boolean inverse, int N, org.ejml.data.DMatrixSparseCSC P)Converts the permutation vector into a matrix.static voidpermutationVector(org.ejml.data.DMatrixSparseCSC P, int[] vector)Converts the permutation matrix into a vectorstatic voidpermute(int[] perm, double[] input, double[] output, int N)Permutes a vector.static voidpermute(int[] permRowInv, org.ejml.data.DMatrixSparseCSC input, int[] permCol, org.ejml.data.DMatrixSparseCSC output)Applies the forward column and inverse row permutation specified by the two vector to the input matrix and save the results in the output matrix.static voidpermuteInv(int[] perm, double[] input, double[] output, int N)Permutes a vector in the inverse.static voidpermuteRowInv(int[] permInv, org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixSparseCSC output)Applies the row permutation specified by the vector to the input matrix and save the results in the output matrix.static voidpermuteSymmetric(org.ejml.data.DMatrixSparseCSC input, int[] permInv, org.ejml.data.DMatrixSparseCSC output, org.ejml.data.IGrowArray gw)Applies the permutation to upper triangular symmetric matrices.static voidremoveZeros(org.ejml.data.DMatrixSparseCSC A, double tol)Removes all elements from the matrix that are > tol.static voidremoveZeros(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixSparseCSC output, double tol)Copies all elements from input into output which are > tol.static voidscale(double scalar, org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B)B = scalar*A.static voidsetIdentity(org.ejml.data.DMatrixSparseCSC A)static booleansolve(org.ejml.data.DMatrixSparseCSC a, org.ejml.data.DMatrixRMaj b, org.ejml.data.DMatrixRMaj x)Solves for x in the following equation:
A*x = bstatic booleansolve(org.ejml.data.DMatrixSparseCSC a, org.ejml.data.DMatrixSparseCSC b, org.ejml.data.DMatrixSparseCSC x)Solves for x in the following equation:
A*x = bstatic org.ejml.data.DMatrixRMajsumCols(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixRMaj output)Computes the sum of each column in the input matrix and returns the results in a vector:
bj = sum(i=1:m ; aij)static org.ejml.data.DMatrixRMajsumRows(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixRMaj output)Computes the sum of each row in the input matrix and returns the results in a vector:
bj = sum(i=1:n ; aji)static voidsymmLowerToFull(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.IGrowArray gw)Given a symmetric matrix, which is represented by a lower triangular matrix, convert it back into a full symmetric matrixstatic doubletrace(org.ejml.data.DMatrixSparseCSC A)This computes the trace of the matrix:
trace = ∑i=1:n { aii }
where n = min(numRows,numCols)static org.ejml.data.DMatrixSparseCSCtranspose(org.ejml.data.DMatrixSparseCSC a, org.ejml.data.DMatrixSparseCSC a_t, org.ejml.data.IGrowArray gw)Perform matrix transposestatic voidzero(org.ejml.data.DMatrixSparseCSC A, int row0, int row1, int col0, int col1)Zeros an inner rectangle inside the matrix.
-
-
-
Method Detail
-
checkIndicesSorted
public static boolean checkIndicesSorted(org.ejml.data.DMatrixSparseCSC A)
Checks to see if row indicies are sorted into ascending order. O(N)- Returns:
- true if sorted and false if not
-
checkStructure
public static boolean checkStructure(org.ejml.data.DMatrixSparseCSC A)
-
checkSortedFlag
public static boolean checkSortedFlag(org.ejml.data.DMatrixSparseCSC A)
-
checkDuplicateElements
public static boolean checkDuplicateElements(org.ejml.data.DMatrixSparseCSC A)
Checks for duplicate elements. A is sorted- Parameters:
A- Matrix to be tested.- Returns:
- true if duplicates or false if false duplicates
-
transpose
public static org.ejml.data.DMatrixSparseCSC transpose(org.ejml.data.DMatrixSparseCSC a, @Nullable org.ejml.data.DMatrixSparseCSC a_t, @Nullable org.ejml.data.IGrowArray gw)Perform matrix transpose- Parameters:
a- Input matrix. Not modifieda_t- Storage for transpose of 'a'. Must be correct shape. data length might be adjusted.gw- (Optional) Storage for internal workspace. Can be null.- Returns:
- The transposed matrix
-
mult
public static void mult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C)
-
mult
public static void mult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, @Nullable org.ejml.data.IGrowArray gw, @Nullable org.ejml.data.DGrowArray gx)Performs matrix multiplication. C = A*B- Parameters:
A- (Input) Matrix. Not modified.B- (Input) Matrix. Not modified.C- (Output) Storage for results. Data length is increased if increased if insufficient.gw- (Optional) Storage for internal workspace. Can be null.gx- (Optional) Storage for internal workspace. Can be null.
-
multTransA
public static void multTransA(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, @Nullable org.ejml.data.IGrowArray gw, @Nullable org.ejml.data.DGrowArray gx)
-
multTransB
public static void multTransB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, @Nullable org.ejml.data.IGrowArray gw, @Nullable org.ejml.data.DGrowArray gx)Performs matrix multiplication. C = A*BT. B needs to be sorted and will be sorted if it has not already been sorted.- Parameters:
A- (Input) Matrix. Not modified.B- (Input) Matrix. Value not modified but indicies will be sorted if not sorted already.C- (Output) Storage for results. Data length is increased if increased if insufficient.gw- (Optional) Storage for internal workspace. Can be null.gx- (Optional) Storage for internal workspace. Can be null.
-
mult
public static void mult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication. C = A*B- Parameters:
A- MatrixB- Dense MatrixC- Dense Matrix
-
multAdd
public static void multAdd(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + A*B
-
multTransA
public static void multTransA(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication. C = AT*B- Parameters:
A- MatrixB- Dense MatrixC- Dense Matrix
-
multAddTransA
public static void multAddTransA(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + AT*B
-
multTransB
public static void multTransB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication. C = A*BT- Parameters:
A- MatrixB- Dense MatrixC- Dense Matrix
-
multAddTransB
public static void multAddTransB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + A*BT
-
multTransAB
public static void multTransAB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)Performs matrix multiplication. C = AT*BT- Parameters:
A- MatrixB- Dense MatrixC- Dense Matrix
-
multAddTransAB
public static void multAddTransAB(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C)C = C + AT*BT
-
innerProductLower
public static void innerProductLower(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, @Nullable org.ejml.data.IGrowArray gw, @Nullable org.ejml.data.DGrowArray gx)Computes the inner product of A times A and stores the results in B. The inner product is symmetric and this function will only store the lower triangle. If the full matrix is needed then. If you need the full matrix usesymmLowerToFull(org.ejml.data.DMatrixSparseCSC, org.ejml.data.DMatrixSparseCSC, org.ejml.data.IGrowArray).B = AT*A
- Parameters:
A- (Input) MatrixB- (Output) Storage for output.gw- (Optional) Workspacegx- (Optional) Workspace
-
symmLowerToFull
public static void symmLowerToFull(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, @Nullable org.ejml.data.IGrowArray gw)Given a symmetric matrix, which is represented by a lower triangular matrix, convert it back into a full symmetric matrix- Parameters:
A- (Input) Lower triangular matrixB- (Output) Symmetric matrix.gw- (Optional) Workspace. Can be null.
-
add
public static void add(double alpha, org.ejml.data.DMatrixSparseCSC A, double beta, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, @Nullable org.ejml.data.IGrowArray gw, @Nullable org.ejml.data.DGrowArray gx)Performs matrix addition:
C = αA + βB- Parameters:
alpha- scalar value multiplied against AA- Matrixbeta- scalar value multiplied against BB- MatrixC- Output matrix.gw- (Optional) Storage for internal workspace. Can be null.gx- (Optional) Storage for internal workspace. Can be null.
-
identity
public static org.ejml.data.DMatrixSparseCSC identity(int length)
-
identity
public static org.ejml.data.DMatrixSparseCSC identity(int numRows, int numCols)
-
setIdentity
public static void setIdentity(org.ejml.data.DMatrixSparseCSC A)
-
scale
public static void scale(double scalar, org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B)B = scalar*A. A and B can be the same instance.- Parameters:
scalar- (Input) Scalar valueA- (Input) Matrix. Not modified.B- (Output) Matrix. Modified.
-
divide
public static void divide(org.ejml.data.DMatrixSparseCSC A, double scalar, org.ejml.data.DMatrixSparseCSC B)B = A/scalar. A and B can be the same instance.- Parameters:
scalar- (Input) Scalar valueA- (Input) Matrix. Not modified.B- (Output) Matrix. Modified.
-
divide
public static void divide(double scalar, org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B)B = scalar/A. A and B can be the same instance. Only non-zero values are affected- Parameters:
A- (Input) Matrix. Not modified.scalar- (Input) Scalar valueB- (Output) Matrix. Modified.
-
changeSign
public static void changeSign(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B)B = -A. Changes the sign of elements in A and stores it in B. A and B can be the same instance.- Parameters:
A- (Input) Matrix. Not modified.B- (Output) Matrix. Modified.
-
elementMinAbs
public static double elementMinAbs(org.ejml.data.DMatrixSparseCSC A)
Returns the value of the element with the smallest abs()- Parameters:
A- (Input) Matrix. Not modified.- Returns:
- scalar
-
elementMaxAbs
public static double elementMaxAbs(org.ejml.data.DMatrixSparseCSC A)
Returns the value of the element with the largest abs()- Parameters:
A- (Input) Matrix. Not modified.- Returns:
- scalar
-
elementMin
public static double elementMin(org.ejml.data.DMatrixSparseCSC A)
Returns the value of the element with the minimum value- Parameters:
A- (Input) Matrix. Not modified.- Returns:
- scalar
-
elementMax
public static double elementMax(org.ejml.data.DMatrixSparseCSC A)
Returns the value of the element with the largest value- Parameters:
A- (Input) Matrix. Not modified.- Returns:
- scalar
-
elementSum
public static double elementSum(org.ejml.data.DMatrixSparseCSC A)
Sum of all elements- Parameters:
A- (Input) Matrix. Not modified.- Returns:
- scalar
-
elementMult
public static void elementMult(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixSparseCSC B, org.ejml.data.DMatrixSparseCSC C, @Nullable org.ejml.data.IGrowArray gw, @Nullable org.ejml.data.DGrowArray gx)Performs an element-wise multiplication.
C[i,j] = A[i,j]*B[i,j]
All matrices must have the same shape.- Parameters:
A- (Input) Matrix.B- (Input) MatrixC- (Output) Matrix. data array is grown to min(A.nz_length,B.nz_length), resulting a in a large speed boost.gw- (Optional) Storage for internal workspace. Can be null.gx- (Optional) Storage for internal workspace. Can be null.
-
columnMaxAbs
public static void columnMaxAbs(org.ejml.data.DMatrixSparseCSC A, double[] values)Finds the maximum abs in each column of A and stores it into values- Parameters:
A- (Input) Matrixvalues- (Output) storage for column max abs
-
multColumns
public static void multColumns(org.ejml.data.DMatrixSparseCSC A, double[] values, int offset)Multiply all elements of column 'i' by value[i]. A[:,i] *= values[i].
Equivalent to A = A*diag(values)- Parameters:
A- (Input/Output) Matrix. Modified.values- (Input) multiplication factor for each columnoffset- (Input) first index in values to start at
-
divideColumns
public static void divideColumns(org.ejml.data.DMatrixSparseCSC A, double[] values, int offset)Divides all elements of column 'i' by values[i]. A[:,i] /= values[i].
Equivalent to A = A*inv(diag(values))- Parameters:
A- (Input/Output) Matrix. Modified.values- (Input) multiplication factor for each columnoffset- (Input) first index in values to start at
-
multRowsCols
public static void multRowsCols(double[] diagA, int offsetA, org.ejml.data.DMatrixSparseCSC B, double[] diagC, int offsetC)Equivalent to multiplying a matrix B by two diagonal matrices. B = A*B*C, where A=diag(a) and C=diag(c).- Parameters:
diagA- Array of length offsteA + B.numRowsoffsetA- First index in AB- Rectangular matrixdiagC- Array of length indexC + B.numColsoffsetC- First index in C
-
divideRowsCols
public static void divideRowsCols(double[] diagA, int offsetA, org.ejml.data.DMatrixSparseCSC B, double[] diagC, int offsetC)Equivalent to multiplying a matrix B by the inverse of two diagonal matrices. B = inv(A)*B*inv(C), where A=diag(a) and C=diag(c).- Parameters:
diagA- Array of length offsteA + B.numRowsoffsetA- First index in AB- Rectangular matrixdiagC- Array of length indexC + B.numColsoffsetC- First index in C
-
diag
public static org.ejml.data.DMatrixSparseCSC diag(double... values)
Returns a diagonal matrix with the specified diagonal elements.- Parameters:
values- values of diagonal elements- Returns:
- A diagonal matrix
-
diag
public static org.ejml.data.DMatrixSparseCSC diag(@Nullable org.ejml.data.DMatrixSparseCSC A, double[] values, int offset, int length)Creates a diagonal matrix from an array. Elements in the array can be offset.- Parameters:
A- (Optional) Storage for diagonal matrix. If null a new one will be declared.values- First index in the diagonal matirxlength- Length of the diagonal matrixoffset- First index in values- Returns:
- The diagonal matrix
-
extractDiag
public static void extractDiag(org.ejml.data.DMatrixSparseCSC src, org.ejml.data.DMatrixSparseCSC dst)Extracts the diagonal elements 'src' write it to the 'dst' vector. 'dst' can either be a row or column vector.
- Parameters:
src- Matrix whose diagonal elements are being extracted. Not modified.dst- A vector the results will be written into. Modified.
-
extractDiag
public static void extractDiag(org.ejml.data.DMatrixSparseCSC src, org.ejml.data.DMatrixRMaj dst)Extracts the diagonal elements 'src' write it to the 'dst' vector. 'dst' can either be a row or column vector.
- Parameters:
src- Matrix whose diagonal elements are being extracted. Not modified.dst- A vector the results will be written into. Modified.
-
permutationMatrix
public static org.ejml.data.DMatrixSparseCSC permutationMatrix(int[] p, boolean inverse, int N, org.ejml.data.DMatrixSparseCSC P)Converts the permutation vector into a matrix. B = P*A. B[p[i],:] = A[i,:]- Parameters:
p- (Input) Permutation vectorinverse- (Input) If it is the inverse. B[i,:] = A[p[i],:)P- (Output) Permutation matrix
-
permutationVector
public static void permutationVector(org.ejml.data.DMatrixSparseCSC P, int[] vector)Converts the permutation matrix into a vector- Parameters:
P- (Input) Permutation matrixvector- (Output) Permutation vector
-
permutationInverse
public static void permutationInverse(int[] original, int[] inverse, int length)Computes the inverse permutation vector- Parameters:
original- Original permutation vectorinverse- It's inverse
-
permutationInverse
public static int[] permutationInverse(int[] original, int length)
-
permuteRowInv
public static void permuteRowInv(int[] permInv, org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixSparseCSC output)Applies the row permutation specified by the vector to the input matrix and save the results in the output matrix. output[perm[j],:] = input[j,:]- Parameters:
permInv- (Input) Inverse permutation vector. Specifies new order of the rows.input- (Input) Matrix which is to be permutedoutput- (Output) Matrix which has the permutation stored in it. Is reshaped.
-
permute
public static void permute(@Nullable int[] permRowInv, org.ejml.data.DMatrixSparseCSC input, @Nullable int[] permCol, org.ejml.data.DMatrixSparseCSC output)Applies the forward column and inverse row permutation specified by the two vector to the input matrix and save the results in the output matrix. output[permRow[j],permCol[i]] = input[j,i]- Parameters:
permRowInv- (Input) Inverse row permutation vector. Null is the same as passing in identity.input- (Input) Matrix which is to be permutedpermCol- (Input) Column permutation vector. Null is the same as passing in identity.output- (Output) Matrix which has the permutation stored in it. Is reshaped.
-
permute
public static void permute(int[] perm, double[] input, double[] output, int N)Permutes a vector. output[i] = input[perm[i]]- Parameters:
perm- (Input) permutation vectorinput- (Input) Vector which is to be permutedoutput- (Output) Where the permuted vector is stored.N- Number of elements in the vector.
-
permuteInv
public static void permuteInv(int[] perm, double[] input, double[] output, int N)Permutes a vector in the inverse. output[perm[k]] = input[k]- Parameters:
perm- (Input) permutation vectorinput- (Input) Vector which is to be permutedoutput- (Output) Where the permuted vector is stored.N- Number of elements in the vector.
-
permuteSymmetric
public static void permuteSymmetric(org.ejml.data.DMatrixSparseCSC input, int[] permInv, org.ejml.data.DMatrixSparseCSC output, @Nullable org.ejml.data.IGrowArray gw)Applies the permutation to upper triangular symmetric matrices. Typically a symmetric matrix only stores the upper triangular part, so normal permutation will have undesirable results, e.g. the zeros will get mixed in and will no longer be symmetric. This algorithm will handle the implicit lower triangular and construct new upper triangular matrix.See page cs_symperm() on Page 22 of "Direct Methods for Sparse Linear Systems"
- Parameters:
input- (Input) Upper triangular symmetric matrix which is to be permuted. Entries below the diagonal are ignored.permInv- (Input) Inverse permutation vector. Specifies new order of the rows and columns.output- (Output) Upper triangular symmetric matrix which has the permutation stored in it. Reshaped.gw- (Optional) Storage for internal workspace. Can be null.
-
concatRows
public static org.ejml.data.DMatrixSparseCSC concatRows(org.ejml.data.DMatrixSparseCSC top, org.ejml.data.DMatrixSparseCSC bottom, @Nullable org.ejml.data.DMatrixSparseCSC out)Concats two matrices along their rows (vertical).- Parameters:
top- Matrix on the topbottom- Matrix on the bototmout- (Output) (Optional) Storage for combined matrix. Resized.- Returns:
- Combination of the two matrices
-
concatColumns
public static org.ejml.data.DMatrixSparseCSC concatColumns(org.ejml.data.DMatrixSparseCSC left, org.ejml.data.DMatrixSparseCSC right, @Nullable org.ejml.data.DMatrixSparseCSC out)Concats two matrices along their columns (horizontal).- Parameters:
left- Matrix on the leftright- Matrix on the rightout- (Output) (Optional) Storage for combined matrix. Resized.- Returns:
- Combination of the two matrices
-
extractColumn
public static org.ejml.data.DMatrixSparseCSC extractColumn(org.ejml.data.DMatrixSparseCSC A, int column, @Nullable org.ejml.data.DMatrixSparseCSC out)Extracts a column from A and stores it into out.- Parameters:
A- (Input) Source matrix. not modified.column- The column in Aout- (Output, Optional) Storage for column vector- Returns:
- The column of A.
-
extractRows
public static org.ejml.data.DMatrixSparseCSC extractRows(org.ejml.data.DMatrixSparseCSC A, int row0, int row1, org.ejml.data.DMatrixSparseCSC out)Creates a submatrix by extracting the specified rows from A. rows = {row0 %le; i %le; row1}.- Parameters:
A- (Input) matrixrow0- First row. Inclusiverow1- Last row+1.out- (Output, Option) Storage for output matrix- Returns:
- The submatrix
-
extract
public static void extract(org.ejml.data.DMatrixSparseCSC src, int srcY0, int srcY1, int srcX0, int srcX1, org.ejml.data.DMatrixSparseCSC dst, int dstY0, int dstX0)Extracts a submatrix from 'src' and inserts it in a submatrix in 'dst'.
si-y0 , j-x0 = oij for all y0 ≤ i < y1 and x0 ≤ j < x1
where 'sij' is an element in the submatrix and 'oij' is an element in the original matrix.WARNING: This is a very slow operation for sparse matrices. The current implementation is simple but involves excessive memory copying.
- Parameters:
src- The original matrix which is to be copied. Not modified.srcX0- Start column.srcX1- Stop column+1.srcY0- Start row.srcY1- Stop row+1.dst- Where the submatrix are stored. Modified.dstY0- Start row in dst.dstX0- start column in dst.
-
fill
public static void fill(org.ejml.data.DMatrixSparseCSC A, double value)Sets every element in the matrix to the specified value. This can require a very large amount of memory and might exceed the maximum array size
Aij = value- Parameters:
A- A matrix whose elements are about to be set. Modified.value- The value each element will have.
-
sumCols
public static org.ejml.data.DMatrixRMaj sumCols(org.ejml.data.DMatrixSparseCSC input, @Nullable org.ejml.data.DMatrixRMaj output)Computes the sum of each column in the input matrix and returns the results in a vector:
bj = sum(i=1:m ; aij)- Parameters:
input- Input matrixoutput- Optional storage for output. Reshaped into a row vector. Modified.- Returns:
- Vector containing the sum of each column
-
minCols
public static org.ejml.data.DMatrixRMaj minCols(org.ejml.data.DMatrixSparseCSC input, @Nullable org.ejml.data.DMatrixRMaj output)Computes the minimum of each column in the input matrix and returns the results in a vector:
bj = min(i=1:m ; aij)- Parameters:
input- Input matrixoutput- Optional storage for output. Reshaped into a row vector. Modified.- Returns:
- Vector containing the minimums of each column
-
maxCols
public static org.ejml.data.DMatrixRMaj maxCols(org.ejml.data.DMatrixSparseCSC input, @Nullable org.ejml.data.DMatrixRMaj output)Computes the maximums of each column in the input matrix and returns the results in a vector:
bj = max(i=1:m ; aij)- Parameters:
input- Input matrixoutput- Optional storage for output. Reshaped into a row vector. Modified.- Returns:
- Vector containing the maximums of each column
-
sumRows
public static org.ejml.data.DMatrixRMaj sumRows(org.ejml.data.DMatrixSparseCSC input, @Nullable org.ejml.data.DMatrixRMaj output)Computes the sum of each row in the input matrix and returns the results in a vector:
bj = sum(i=1:n ; aji)- Parameters:
input- Input matrixoutput- Optional storage for output. Reshaped into a column vector. Modified.- Returns:
- Vector containing the sum of each row
-
minRows
public static org.ejml.data.DMatrixRMaj minRows(org.ejml.data.DMatrixSparseCSC input, @Nullable org.ejml.data.DMatrixRMaj output, @Nullable org.ejml.data.IGrowArray gw)Computes the minimum of each row in the input matrix and returns the results in a vector:
bj = min(i=1:n ; aji)- Parameters:
input- Input matrixoutput- Optional storage for output. Reshaped into a column vector. Modified.gw- work space- Returns:
- Vector containing the minimum of each row
-
maxRows
public static org.ejml.data.DMatrixRMaj maxRows(org.ejml.data.DMatrixSparseCSC input, @Nullable org.ejml.data.DMatrixRMaj output, @Nullable org.ejml.data.IGrowArray gw)Computes the maximum of each row in the input matrix and returns the results in a vector:
bj = max(i=1:n ; aji)- Parameters:
input- Input matrixoutput- Optional storage for output. Reshaped into a column vector. Modified.gw- work space- Returns:
- Vector containing the maximum of each row
-
zero
public static void zero(org.ejml.data.DMatrixSparseCSC A, int row0, int row1, int col0, int col1)Zeros an inner rectangle inside the matrix.- Parameters:
A- Matrix that is to be modified.row0- Start row.row1- Stop row+1.col0- Start column.col1- Stop column+1.
-
dotInnerColumns
public static double dotInnerColumns(org.ejml.data.DMatrixSparseCSC A, int colA, org.ejml.data.DMatrixSparseCSC B, int colB, org.ejml.data.IGrowArray gw, org.ejml.data.DGrowArray gx)Computes the inner product of two column vectors taken from the input matrices.dot = A(:,colA)'*B(:,colB)
- Parameters:
A- MatrixcolA- Column in AB- MatrixcolB- Column in B- Returns:
- Dot product
-
solve
public static boolean solve(org.ejml.data.DMatrixSparseCSC a, org.ejml.data.DMatrixRMaj b, org.ejml.data.DMatrixRMaj x)Solves for x in the following equation:
A*x = bIf the system could not be solved then false is returned. If it returns true that just means the algorithm finished operating, but the results could still be bad because 'A' is singular or nearly singular.
If repeat calls to solve are being made then one should consider using
LinearSolverFactory_DSCCinstead.It is ok for 'b' and 'x' to be the same matrix.
- Parameters:
a- (Input) A matrix that is m by n. Not modified.b- (Input) A matrix that is n by k. Not modified.x- (Output) A matrix that is m by k. Modified.- Returns:
- true if it could invert the matrix false if it could not.
-
solve
public static boolean solve(org.ejml.data.DMatrixSparseCSC a, org.ejml.data.DMatrixSparseCSC b, org.ejml.data.DMatrixSparseCSC x)Solves for x in the following equation:
A*x = bIf the system could not be solved then false is returned. If it returns true that just means the algorithm finished operating, but the results could still be bad because 'A' is singular or nearly singular.
If repeat calls to solve are being made then one should consider using
LinearSolverFactory_DSCCinstead.It is ok for 'b' and 'x' to be the same matrix.
- Parameters:
a- (Input) A matrix that is m by n. Not modified.b- (Input) A matrix that is n by k. Not modified.x- (Output) A matrix that is m by k. Modified.- Returns:
- true if it could invert the matrix false if it could not.
-
invert
public static boolean invert(org.ejml.data.DMatrixSparseCSC A, org.ejml.data.DMatrixRMaj inverse)Performs a matrix inversion operation that does not modify the original and stores the results in another matrix. The two matrices must have the same dimension.
B = A-1If the algorithm could not invert the matrix then false is returned. If it returns true that just means the algorithm finished. The results could still be bad because the matrix is singular or nearly singular.
For medium to large matrices there might be a slight performance boost to using
LinearSolverFactory_DSCCinstead.- Parameters:
A- (Input) The matrix that is to be inverted. Not modified.inverse- (Output) Where the inverse matrix is stored. Modified.- Returns:
- true if it could invert the matrix false if it could not.
-
det
public static double det(org.ejml.data.DMatrixSparseCSC A)
Returns the determinant of the matrix. If the inverse of the matrix is also needed, then usingLUDecomposition_F64directly (or any similar algorithm) can be more efficient.- Parameters:
A- The matrix whose determinant is to be computed. Not modified.- Returns:
- The determinant.
-
removeZeros
public static void removeZeros(org.ejml.data.DMatrixSparseCSC input, org.ejml.data.DMatrixSparseCSC output, double tol)Copies all elements from input into output which are > tol.- Parameters:
input- (Input) input matrix. Not modified.output- (Output) Output matrix. Modified and shaped to match input.tol- Tolerance for defining zero
-
removeZeros
public static void removeZeros(org.ejml.data.DMatrixSparseCSC A, double tol)Removes all elements from the matrix that are > tol. The modification is done in place and no temporary storage is declared.- Parameters:
A- (Input/Output) input matrix. Modified.tol- Tolerance for defining zero
-
multRows
public static void multRows(double[] diag, int offset, org.ejml.data.DMatrixSparseCSC A)Multiply all elements of row 'i' by value[i]. A[i,:] *= values[i]- Parameters:
diag- (Input) multiplication factorsoffset- (Input) First index in valuesA- (Input/Output) Matrix. Modified.
-
divideRows
public static void divideRows(double[] diag, int offset, org.ejml.data.DMatrixSparseCSC A)Divides all elements of row 'i' by value[i]. A[i,:] /= values[i]- Parameters:
diag- (Input) division factorsoffset- (Input) First index in valuesA- (Input/Output) Matrix. Modified.
-
trace
public static double trace(org.ejml.data.DMatrixSparseCSC A)
This computes the trace of the matrix:
trace = ∑i=1:n { aii }
where n = min(numRows,numCols)- Parameters:
A- (Input) Matrix. Not modified.
-
-