public class SpecializedOps extends Object
| Constructor and Description |
|---|
SpecializedOps() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addIdentity(RowD1Matrix64F A,
RowD1Matrix64F B,
double alpha)
Performs the following operation:
B = A + αI |
static DenseMatrix64F |
copyChangeRow(int[] order,
DenseMatrix64F src,
DenseMatrix64F dst)
Creates a copy of a matrix but swaps the rows as specified by the order array.
|
static DenseMatrix64F |
copyTriangle(DenseMatrix64F src,
DenseMatrix64F dst,
boolean upper)
Copies just the upper or lower triangular portion of a matrix.
|
static DenseMatrix64F |
createReflector(DenseMatrix64F u,
double gamma)
Creates a reflector from the provided vector and gamma.
Q = I - γ u uT |
static DenseMatrix64F |
createReflector(RowD1Matrix64F u)
Creates a reflector from the provided vector.
Q = I - γ u uT γ = 2/||u||2 |
static double |
diagProd(RowD1Matrix64F T)
Computes the product of the diagonal elements.
|
static double |
diffNormF_fast(D1Matrix64F a,
D1Matrix64F b) |
static double |
diffNormF(D1Matrix64F a,
D1Matrix64F b)
Computes the F norm of the difference between the two Matrices:
Sqrt{∑i=1:m ∑j=1:n ( aij - bij)2} |
static double |
diffNormP1(D1Matrix64F a,
D1Matrix64F 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 double |
elementSumSq(D1Matrix64F m)
Sums up the square of each element in the matrix.
|
static DenseMatrix64F |
pivotMatrix(DenseMatrix64F ret,
int[] pivots,
int numPivots,
boolean transposed)
Creates a pivot matrix that exchanges the rows in a matrix:
A' = P*A |
static double |
qualityTriangular(boolean upper,
D1Matrix64F T)
Computes the quality of a triangular matrix, where the quality of a matrix
is defined in
LinearSolver.quality(). |
static DenseMatrix64F[] |
splitIntoVectors(RowD1Matrix64F A,
boolean column)
Takes a matrix and splits it into a set of row or column vectors.
|
static void |
subvector(RowD1Matrix64F A,
int rowA,
int colA,
int length,
boolean row,
int offsetV,
RowD1Matrix64F v)
Extracts a row or column vector from matrix A.
|
public static DenseMatrix64F createReflector(RowD1Matrix64F u)
Creates a reflector from the provided vector.
Q = I - γ u uT
γ = 2/||u||2
In practice VectorVectorMult.householder(double, org.ejml.data.D1Matrix64F, org.ejml.data.D1Matrix64F, org.ejml.data.D1Matrix64F) multHouseholder}
should be used for performance reasons since there is no need to calculate Q explicitly.
u - A vector. Not modified.public static DenseMatrix64F createReflector(DenseMatrix64F u, double gamma)
Creates a reflector from the provided vector and gamma.
Q = I - γ u uT
In practice VectorVectorMult.householder(double, org.ejml.data.D1Matrix64F, org.ejml.data.D1Matrix64F, org.ejml.data.D1Matrix64F) multHouseholder}
should be used for performance reasons since there is no need to calculate Q explicitly.
u - A vector. Not modified.gamma - To produce a reflector gamma needs to be equal to 2/||u||.public static DenseMatrix64F copyChangeRow(int[] order, DenseMatrix64F src, DenseMatrix64F dst)
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.public static DenseMatrix64F copyTriangle(DenseMatrix64F src, DenseMatrix64F dst, boolean upper)
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.public static double diffNormF(D1Matrix64F a, D1Matrix64F 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.
a - m by n matrix. Not modified.b - m by n matrix. Not modified.NormOps.fastNormF(org.ejml.data.D1Matrix64F)public static double diffNormF_fast(D1Matrix64F a, D1Matrix64F b)
public static double diffNormP1(D1Matrix64F a, D1Matrix64F 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.
a - m by n matrix. Not modified.b - m by n matrix. Not modified.public static void addIdentity(RowD1Matrix64F A, RowD1Matrix64F B, double alpha)
Performs the following operation:
B = A + αI
A - A square matrix. Not modified.B - A square matrix that the results are saved to. Modified.alpha - Scaling factor for the identity matrix.public static void subvector(RowD1Matrix64F A, int rowA, int colA, int length, boolean row, int offsetV, RowD1Matrix64F 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.
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.public static DenseMatrix64F[] splitIntoVectors(RowD1Matrix64F A, boolean column)
A - original matrix.column - If true then column vectors will be created.public static DenseMatrix64F pivotMatrix(DenseMatrix64F 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.
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.public static double diagProd(RowD1Matrix64F T)
T - A matrix.public static double qualityTriangular(boolean upper,
D1Matrix64F T)
LinearSolver.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.upper - if it is upper triangular or not.T - A matrix. @return product of the diagonal elements.public static double elementSumSq(D1Matrix64F m)
m - Matrix.Copyright © 2013. All Rights Reserved.