Class QRDecompositionHouseholder_B64
- java.lang.Object
-
- org.ejml.alg.block.decomposition.qr.QRDecompositionHouseholder_B64
-
- All Implemented Interfaces:
- DecompositionInterface<BlockMatrix64F>, QRDecomposition<BlockMatrix64F>
public class QRDecompositionHouseholder_B64 extends java.lang.Object implements QRDecomposition<BlockMatrix64F>
QR decomposition for
BlockMatrix64Fusing householder reflectors. The decomposition is performed by computing a QR decomposition for each block column as is normally done, seeQRDecompositionHouseholder_D64. The reflectors are then combined and applied to the remainder of the matrix. This process is repeated until all the block columns have been processedThe input matrix is modified and used to store the decomposition. Reflectors are stored in the lower triangle columns. The first element of the reflector is implicitly assumed to be one.
Each iteration can be sketched as follows:
QR_Decomposition( A(:,i-r to i) ) W=computeW( A(:,i-r to i) ) A(:,i:n) = (I + W*YT)TA(:,i:n)
Where r is the block size, i is the submatrix being considered, A is the input matrix, Y is a matrix containing the reflectors just computed, and W is computed usingBlockHouseHolder.computeW_Column(int, org.ejml.data.D1Submatrix64F, org.ejml.data.D1Submatrix64F, double[], double[], int).Based upon "Block Householder QR Factorization" pg 255 in "Matrix Computations" 3rd Ed. 1996 by Gene H. Golub and Charles F. Van Loan.
-
-
Constructor Summary
Constructors Constructor and Description QRDecompositionHouseholder_B64()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidapplyQ(BlockMatrix64F B)Multiplies the provided matrix by Q using householder reflectors.voidapplyQ(BlockMatrix64F B, boolean isIdentity)Specialized version of applyQ() that allows the zeros in an identity matrix to be taken advantage of depending on if isIdentity is true or not.voidapplyQTran(BlockMatrix64F B)Multiplies the provided matrix by QT using householder reflectors.booleandecompose(BlockMatrix64F orig)Computes the decomposition of the input matrix.BlockMatrix64FgetQ(BlockMatrix64F Q, boolean compact)Returns the Q matrix from the decomposition.BlockMatrix64FgetQR()This is the input matrix after it has been overwritten with the decomposition.BlockMatrix64FgetR(BlockMatrix64F R, boolean compact)Returns the R matrix from the decomposition.static BlockMatrix64FinitializeQ(BlockMatrix64F Q, int numRows, int numCols, int blockLength, boolean compact)Sanity checks the input or declares a new matrix.booleaninputModified()The input matrix is always modified.voidsetSaveW(boolean saveW)Sets if it should internally save the W matrix before performing the decomposition.
-
-
-
Method Detail
-
getQR
public BlockMatrix64F getQR()
This is the input matrix after it has been overwritten with the decomposition.- Returns:
- Internal matrix used to store decomposition.
-
setSaveW
public void setSaveW(boolean saveW)
Sets if it should internally save the W matrix before performing the decomposition. Must be set before decomposition the matrix.
Saving W can result in about a 5% savings when solving systems around a height of 5k. The price is that it needs to save a matrix the size of the input matrix.
- Parameters:
saveW- If the W matrix should be saved or not.
-
getQ
public BlockMatrix64F getQ(BlockMatrix64F Q, boolean compact)
Description copied from interface:QRDecompositionReturns the Q matrix from the decomposition. Should only be called after
DecompositionInterface.decompose(org.ejml.data.Matrix)has been called.If parameter Q is not null, then that matrix is used to store the Q matrix. Otherwise a new matrix is created.
- Specified by:
getQin interfaceQRDecomposition<BlockMatrix64F>- Parameters:
Q- If not null then the Q matrix is written to it. Modified.compact- If true an m by n matrix is created, otherwise n by n.- Returns:
- The Q matrix.
-
initializeQ
public static BlockMatrix64F initializeQ(BlockMatrix64F Q, int numRows, int numCols, int blockLength, boolean compact)
Sanity checks the input or declares a new matrix. Return matrix is an identity matrix.
-
applyQ
public void applyQ(BlockMatrix64F B)
Multiplies the provided matrix by Q using householder reflectors. This is more efficient that computing Q then applying it to the matrix.
B = Q * B
- Parameters:
B- Matrix which Q is applied to. Modified.
-
applyQ
public void applyQ(BlockMatrix64F B, boolean isIdentity)
Specialized version of applyQ() that allows the zeros in an identity matrix to be taken advantage of depending on if isIdentity is true or not.- Parameters:
B-isIdentity- If B is an identity matrix.
-
applyQTran
public void applyQTran(BlockMatrix64F B)
Multiplies the provided matrix by QT using householder reflectors. This is more efficient that computing Q then applying it to the matrix.
Q = Q*(I - γ W*Y^T)
QR = A => R = Q^T*A = (Q3^T * (Q2^T * (Q1^t * A)))- Parameters:
B- Matrix which Q is applied to. Modified.
-
getR
public BlockMatrix64F getR(BlockMatrix64F R, boolean compact)
Description copied from interface:QRDecompositionReturns the R matrix from the decomposition. Should only be called after
DecompositionInterface.decompose(org.ejml.data.Matrix)has been.If setZeros is true then an n × m matrix is required and all the elements are set. If setZeros is false then the matrix must be at least m × m and only the upper triangular elements are set.
If parameter R is not null, then that matrix is used to store the R matrix. Otherwise a new matrix is created.
- Specified by:
getRin interfaceQRDecomposition<BlockMatrix64F>- Parameters:
R- If not null then the R matrix is written to it. Modified.compact- If true only the upper triangular elements are set- Returns:
- The R matrix.
-
decompose
public boolean decompose(BlockMatrix64F orig)
Description copied from interface:DecompositionInterfaceComputes the decomposition of the input matrix. Depending on the implementation the input matrix might be stored internally or modified. If it is modified then the functionDecompositionInterface.inputModified()will return true and the matrix should not be modified until the decomposition is no longer needed.- Specified by:
decomposein interfaceDecompositionInterface<BlockMatrix64F>- Parameters:
orig- The matrix which is being decomposed. Modification is implementation dependent.- Returns:
- Returns if it was able to decompose the matrix.
-
inputModified
public boolean inputModified()
The input matrix is always modified.- Specified by:
inputModifiedin interfaceDecompositionInterface<BlockMatrix64F>- Returns:
- Returns true since the input matrix is modified.
-
-
DMelt 3.0 © DataMelt by jWork.ORG