Class SpecializedOps_DDRM
public class SpecializedOps_DDRM
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description SpecializedOps_DDRM() -
Method Summary
Modifier and Type Method Description static voidaddIdentity(org.ejml.data.DMatrix1Row A, org.ejml.data.DMatrix1Row B, double alpha)Performs the following operation:
B = A + αIstatic org.ejml.data.DMatrixRMajcopyChangeRow(int[] order, org.ejml.data.DMatrixRMaj src, @Nullable org.ejml.data.DMatrixRMaj dst)Creates a copy of a matrix but swaps the rows as specified by the order array.static org.ejml.data.DMatrixRMajcopyTriangle(org.ejml.data.DMatrixRMaj src, @Nullable org.ejml.data.DMatrixRMaj dst, boolean upper)Copies just the upper or lower triangular portion of a matrix.static org.ejml.data.DMatrixRMajcreateReflector(org.ejml.data.DMatrix1Row u)Creates a reflector from the provided vector.
Q = I - γ u uT
γ = 2/||u||2static org.ejml.data.DMatrixRMajcreateReflector(org.ejml.data.DMatrixRMaj u, double gamma)Creates a reflector from the provided vector and gamma.
Q = I - γ u uTstatic doublediagProd(org.ejml.data.DMatrix1Row T)Computes the product of the diagonal elements.static doublediffNormF(org.ejml.data.DMatrixD1 a, org.ejml.data.DMatrixD1 b)Computes the F norm of the difference between the two Matrices:
Sqrt{∑i=1:m ∑j=1:n ( aij - bij)2}static doublediffNormF_fast(org.ejml.data.DMatrixD1 a, org.ejml.data.DMatrixD1 b)static doublediffNormP1(org.ejml.data.DMatrixD1 a, org.ejml.data.DMatrixD1 b)Computes the p=1 p-norm of the difference between the two Matrices:
∑i=1:m ∑j=1:n | aij - bij|
where |x| is the absolute value of x.static doubleelementDiagonalMaxAbs(org.ejml.data.DMatrixD1 a)Returns the absolute value of the digonal element in the matrix that has the largest absolute value.
Max{ |aij| } for all i and jstatic doubleelementSumSq(org.ejml.data.DMatrixD1 m)Sums up the square of each element in the matrix.static voidmultLowerTranA(org.ejml.data.DMatrixRMaj mat)Performs L = LT*Lstatic voidmultLowerTranB(org.ejml.data.DMatrixRMaj mat)Performs L = L*LTstatic org.ejml.data.DMatrixRMajpivotMatrix(@Nullable org.ejml.data.DMatrixRMaj ret, int[] pivots, int numPivots, boolean transposed)Creates a pivot matrix that exchanges the rows in a matrix:
A' = P*Astatic doublequalityTriangular(org.ejml.data.DMatrixD1 T)Computes the quality of a triangular matrix, where the quality of a matrix is defined inLinearSolver.quality().static org.ejml.data.DMatrixRMaj[]splitIntoVectors(org.ejml.data.DMatrix1Row A, boolean column)Takes a matrix and splits it into a set of row or column vectors.static voidsubvector(org.ejml.data.DMatrix1Row A, int rowA, int colA, int length, boolean row, int offsetV, org.ejml.data.DMatrix1Row v)Extracts a row or column vector from matrix A.
-
Constructor Details
-
SpecializedOps_DDRM
public SpecializedOps_DDRM()
-
-
Method Details
-
createReflector
public static org.ejml.data.DMatrixRMaj createReflector(org.ejml.data.DMatrix1Row u)Creates a reflector from the provided vector.
Q = I - γ u uT
γ = 2/||u||2In practice
VectorVectorMult_DDRM.householder(double, DMatrixD1, DMatrixD1, DMatrixD1)multHouseholder} should be used for performance reasons since there is no need to calculate Q explicitly.- Parameters:
u- A vector. Not modified.- Returns:
- An orthogonal reflector.
-
createReflector
public static org.ejml.data.DMatrixRMaj createReflector(org.ejml.data.DMatrixRMaj u, double gamma)Creates a reflector from the provided vector and gamma.
Q = I - γ u uT
In practice
VectorVectorMult_DDRM.householder(double, DMatrixD1, DMatrixD1, DMatrixD1)multHouseholder} should be used for performance reasons since there is no need to calculate Q explicitly.- Parameters:
u- A vector. Not modified.gamma- To produce a reflector gamma needs to be equal to 2/||u||.- Returns:
- An orthogonal reflector.
-
copyChangeRow
public static org.ejml.data.DMatrixRMaj copyChangeRow(int[] order, org.ejml.data.DMatrixRMaj src, @Nullable @Nullable org.ejml.data.DMatrixRMaj dst)Creates a copy of a matrix but swaps the rows as specified by the order array.- Parameters:
order- Specifies which row in the dest corresponds to a row in the src. Not modified.src- The original matrix. Not modified.dst- A Matrix that is a row swapped copy of src. Modified.
-
copyTriangle
public static org.ejml.data.DMatrixRMaj copyTriangle(org.ejml.data.DMatrixRMaj src, @Nullable @Nullable org.ejml.data.DMatrixRMaj dst, boolean upper)Copies just the upper or lower triangular portion of a matrix.- Parameters:
src- Matrix being copied. Not modified.dst- Where just a triangle from src is copied. If null a new one will be created. Modified.upper- If the upper or lower triangle should be copied.- Returns:
- The copied matrix.
-
multLowerTranB
public static void multLowerTranB(org.ejml.data.DMatrixRMaj mat)Performs L = L*LT -
multLowerTranA
public static void multLowerTranA(org.ejml.data.DMatrixRMaj mat)Performs L = LT*L -
diffNormF
public static double diffNormF(org.ejml.data.DMatrixD1 a, org.ejml.data.DMatrixD1 b)Computes the F norm of the difference between the two Matrices:
Sqrt{∑i=1:m ∑j=1:n ( aij - bij)2}This is often used as a cost function.
- Parameters:
a- m by n matrix. Not modified.b- m by n matrix. Not modified.- Returns:
- The F normal of the difference matrix.
- See Also:
NormOps_DDRM.fastNormF(org.ejml.data.DMatrixD1)
-
diffNormF_fast
public static double diffNormF_fast(org.ejml.data.DMatrixD1 a, org.ejml.data.DMatrixD1 b) -
diffNormP1
public static double diffNormP1(org.ejml.data.DMatrixD1 a, org.ejml.data.DMatrixD1 b)Computes the p=1 p-norm of the difference between the two Matrices:
∑i=1:m ∑j=1:n | aij - bij|
where |x| is the absolute value of x.This is often used as a cost function.
- Parameters:
a- m by n matrix. Not modified.b- m by n matrix. Not modified.- Returns:
- The p=1 p-norm of the difference matrix.
-
addIdentity
public static void addIdentity(org.ejml.data.DMatrix1Row A, org.ejml.data.DMatrix1Row B, double alpha)Performs the following operation:
B = A + αI- Parameters:
A- A square matrix. Not modified.B- A square matrix that the results are saved to. Modified.alpha- Scaling factor for the identity matrix.
-
subvector
public static void subvector(org.ejml.data.DMatrix1Row A, int rowA, int colA, int length, boolean row, int offsetV, org.ejml.data.DMatrix1Row v)Extracts a row or column vector from matrix A. The first element in the matrix is at element (rowA,colA). The next 'length' elements are extracted along a row or column. The results are put into vector 'v' start at its element v0.
- Parameters:
A- Matrix that the vector is being extracted from. Not modified.rowA- Row of the first element that is extracted.colA- Column of the first element that is extracted.length- Length of the extracted vector.row- If true a row vector is extracted, otherwise a column vector is extracted.offsetV- First element in 'v' where the results are extracted to.v- Vector where the results are written to. Modified.
-
splitIntoVectors
public static org.ejml.data.DMatrixRMaj[] splitIntoVectors(org.ejml.data.DMatrix1Row A, boolean column)Takes a matrix and splits it into a set of row or column vectors.- Parameters:
A- original matrix.column- If true then column vectors will be created.- Returns:
- Set of vectors.
-
pivotMatrix
public static org.ejml.data.DMatrixRMaj pivotMatrix(@Nullable @Nullable org.ejml.data.DMatrixRMaj ret, int[] pivots, int numPivots, boolean transposed)Creates a pivot matrix that exchanges the rows in a matrix:
A' = P*A
For example, if element 0 in 'pivots' is 2 then the first row in A' will be the 3rd row in A.
- Parameters:
ret- If null then a new matrix is declared otherwise the results are written to it. Is modified.pivots- Specifies the new order of rows in a matrix.numPivots- How many elements in pivots are being used.transposed- If the transpose of the matrix is returned.- Returns:
- A pivot matrix.
-
diagProd
public static double diagProd(org.ejml.data.DMatrix1Row T)Computes the product of the diagonal elements. For a diagonal or triangular matrix this is the determinant.- Parameters:
T- A matrix.- Returns:
- product of the diagonal elements.
-
elementDiagonalMaxAbs
public static double elementDiagonalMaxAbs(org.ejml.data.DMatrixD1 a)Returns the absolute value of the digonal element in the matrix that has the largest absolute value.
Max{ |aij| } for all i and j
- Parameters:
a- A matrix. Not modified.- Returns:
- The max abs element value of the matrix.
-
qualityTriangular
public static double qualityTriangular(org.ejml.data.DMatrixD1 T)Computes the quality of a triangular matrix, where the quality of a matrix is defined inLinearSolver.quality(). In this situation the quality os the absolute value of the product of each diagonal element divided by the magnitude of the largest diagonal element. If all diagonal elements are zero then zero is returned.- Parameters:
T- A matrix.- Returns:
- the quality of the system.
-
elementSumSq
public static double elementSumSq(org.ejml.data.DMatrixD1 m)Sums up the square of each element in the matrix. This is equivalent to the Frobenius norm squared.- Parameters:
m- Matrix.- Returns:
- Sum of elements squared.
-