Class QRColPivDecompositionHouseholderColumn_FDRM
- All Implemented Interfaces:
DecompositionInterface<FMatrixRMaj>
,QRDecomposition<FMatrixRMaj>
,QRPDecomposition<FMatrixRMaj>
,QRPDecomposition_F32<FMatrixRMaj>
Performs QR decomposition with column pivoting. To prevent overflow/underflow the whole matrix
is normalized by the max value, but columns are not normalized individually any more. To enable
code reuse it extends QRDecompositionHouseholderColumn_FDRM
and functions from that class
are used whenever possible. Columns are transposed into single arrays, which allow for
fast pivots.
Decomposition: A*P = Q*R
Based off the description in "Fundamentals of Matrix Computations", 2nd by David S. Watkins.
-
Field Summary
Modifier and TypeFieldDescriptionprotected float[]
protected int[]
protected int
protected float
-
Constructor Summary
ConstructorDescriptionQRColPivDecompositionHouseholderColumn_FDRM
(float singularThreshold) Configure parameters. -
Method Summary
Modifier and TypeMethodDescriptionboolean
To decompose the matrix 'A' it must have full rank.getColPivotMatrix
(@Nullable FMatrixRMaj P) Creates the column pivot matrix.int[]
Ordering of each column after pivoting.getQ
(@Nullable FMatrixRMaj Q, boolean compact) Computes the Q matrix from the information stored in the QR matrix.int
getRank()
Returns the rank as determined by the algorithm.protected boolean
householderPivot
(int j) Computes the householder vector "u" for the first column of submatrix j.void
setExpectedMaxSize
(int numRows, int numCols) void
setSingularThreshold
(float threshold) Specifies the threshold used to flag a column as being singular.protected void
Sets the initial pivot ordering and compute the F-norm squared for each columnprotected void
swapColumns
(int j) Finds the column with the largest normal and makes that the first columnprotected void
updateNorms
(int j) Performs an efficient update of each columns' normMethods inherited from class org.ejml.dense.row.decomposition.qr.QRDecompositionHouseholderColumn_FDRM
convertToColumnMajor, getGammas, getQR, getR, householder, inputModified, updateA
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ejml.interfaces.decomposition.DecompositionInterface
inputModified
Methods inherited from interface org.ejml.interfaces.decomposition.QRDecomposition
getR
-
Field Details
-
pivots
protected int[] pivots -
normsCol
protected float[] normsCol -
singularThreshold
protected float singularThreshold -
rank
protected int rank
-
-
Constructor Details
-
QRColPivDecompositionHouseholderColumn_FDRM
public QRColPivDecompositionHouseholderColumn_FDRM(float singularThreshold) Configure parameters.- Parameters:
singularThreshold
- The singular threshold.
-
QRColPivDecompositionHouseholderColumn_FDRM
public QRColPivDecompositionHouseholderColumn_FDRM()
-
-
Method Details
-
setSingularThreshold
public void setSingularThreshold(float threshold) Description copied from interface:QRPDecomposition_F32
Specifies the threshold used to flag a column as being singular. The specified threshold is relative and will very depending on the system. The default value is UtilEJML.F_EPS.
- Specified by:
setSingularThreshold
in interfaceQRPDecomposition_F32<FMatrixRMaj>
- Parameters:
threshold
- Singular threshold.
-
setExpectedMaxSize
public void setExpectedMaxSize(int numRows, int numCols) - Overrides:
setExpectedMaxSize
in classQRDecompositionHouseholderColumn_FDRM
-
getQ
Computes the Q matrix from the information stored in the QR matrix. This operation requires about 4(m2n-mn2+n3/3) flops.- Specified by:
getQ
in interfaceQRDecomposition<FMatrixRMaj>
- Overrides:
getQ
in classQRDecompositionHouseholderColumn_FDRM
- Parameters:
Q
- The orthogonal Q matrix.compact
- If true an m by n matrix is created, otherwise n by n.- Returns:
- The Q matrix.
-
decompose
To decompose the matrix 'A' it must have full rank. 'A' is a 'm' by 'n' matrix. It requires about 2n*m2-2m2/3 flops.
The matrix provided here can be of different dimension than the one specified in the constructor. It just has to be smaller than or equal to it.
- Specified by:
decompose
in interfaceDecompositionInterface<FMatrixRMaj>
- Overrides:
decompose
in classQRDecompositionHouseholderColumn_FDRM
- Parameters:
A
- The matrix which is being decomposed. Modification is implementation dependent.- Returns:
- Returns if it was able to decompose the matrix.
-
setupPivotInfo
protected void setupPivotInfo()Sets the initial pivot ordering and compute the F-norm squared for each column -
updateNorms
protected void updateNorms(int j) Performs an efficient update of each columns' norm -
swapColumns
protected void swapColumns(int j) Finds the column with the largest normal and makes that the first column- Parameters:
j
- Current column being inspected
-
householderPivot
protected boolean householderPivot(int j) Computes the householder vector "u" for the first column of submatrix j. The already computed norm is used and checks to see if the matrix is singular at this point.
Q = I - γuuT
This function finds the values of 'u' and 'γ'.
- Parameters:
j
- Which submatrix to work off of.- Returns:
- false if it is degenerate
-
getRank
public int getRank()Description copied from interface:QRPDecomposition
Returns the rank as determined by the algorithm. This is dependent upon a fixed threshold and might not be appropriate for some applications.- Specified by:
getRank
in interfaceQRPDecomposition<FMatrixRMaj>
- Returns:
- Matrix's rank
-
getColPivots
public int[] getColPivots()Description copied from interface:QRPDecomposition
Ordering of each column after pivoting. The current column i was original at column pivot[i].- Specified by:
getColPivots
in interfaceQRPDecomposition<FMatrixRMaj>
- Returns:
- Order of columns.
-
getColPivotMatrix
Description copied from interface:QRPDecomposition
Creates the column pivot matrix.- Specified by:
getColPivotMatrix
in interfaceQRPDecomposition<FMatrixRMaj>
- Parameters:
P
- Optional storage for pivot matrix. If null a new matrix will be created.- Returns:
- The pivot matrix.
-