org.ejml.alg.dense.decomposition.svd.implicitqr
Class SvdImplicitQrAlgorithm
- java.lang.Object
-
- org.ejml.alg.dense.decomposition.svd.implicitqr.SvdImplicitQrAlgorithm
-
- Direct Known Subclasses:
- SvdImplicitQrAlgorithmSmart
public class SvdImplicitQrAlgorithm extends java.lang.ObjectComputes the QR decomposition of a bidiagonal matrix. Internally this matrix is stored as two arrays. Shifts can either be provided to it or it can generate the shifts on its own. It optionally computes the U and V matrices. This comparability allows it to be used to compute singular values and associated matrices efficiently.
A = U*S*VT
where A is the original m by n matrix.Based off of the outline provided in:
David S. Watkins, "Fundamentals of Matrix Computations," Second Edition. Page 404-411Note: To watch it process the matrix step by step uncomment commented out code.
-
-
Constructor Summary
Constructors Constructor and Description SvdImplicitQrAlgorithm()SvdImplicitQrAlgorithm(boolean fastValues)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean_process()voidexceptionShift()It is possible for the QR algorithm to get stuck in a loop because of symmetries.double[]getDiag()doublegetMaxValue()intgetNumberOfSingularValues()double[]getOff()doublegetSingularValue(int index)double[]getSingularValues()DenseMatrix64FgetUt()DenseMatrix64FgetVt()voidincrementSteps()voidinitParam(int M, int N)booleanisDiagonalZero(int i)booleanisOffZero(int i)booleannextSplit()Tells it to process the submatrix at the next split.voidperformImplicitSingleStep(double scale, double lambda, boolean byAngle)Given the lambda value perform an implicit QR step on the matrix.voidprintMatrix()booleanprocess()booleanprocess(double[] values)Perform a sequence of steps based off of the singular values provided.voidresetSteps()doubleselectWilkinsonShift(double scale)Selects the Wilkinson's shift for BTB.voidsetFastValues(boolean b)voidsetMatrix(int numRows, int numCols, double[] diag, double[] off)voidsetMaxValue(double maxValue)voidsetSubmatrix(int x1, int x2)voidsetUt(DenseMatrix64F ut)voidsetVt(DenseMatrix64F vt)double[]swapDiag(double[] diag)double[]swapOff(double[] off)
-
-
-
Constructor Detail
-
SvdImplicitQrAlgorithm
public SvdImplicitQrAlgorithm(boolean fastValues)
-
SvdImplicitQrAlgorithm
public SvdImplicitQrAlgorithm()
-
-
Method Detail
-
getUt
public DenseMatrix64F getUt()
-
setUt
public void setUt(DenseMatrix64F ut)
-
getVt
public DenseMatrix64F getVt()
-
setVt
public void setVt(DenseMatrix64F vt)
-
setMatrix
public void setMatrix(int numRows, int numCols, double[] diag, double[] off)
-
swapDiag
public double[] swapDiag(double[] diag)
-
swapOff
public double[] swapOff(double[] off)
-
setMaxValue
public void setMaxValue(double maxValue)
-
initParam
public void initParam(int M, int N)
-
process
public boolean process()
-
process
public boolean process(double[] values)
Perform a sequence of steps based off of the singular values provided.- Parameters:
values-- Returns:
-
_process
public boolean _process()
-
incrementSteps
public void incrementSteps()
-
isOffZero
public boolean isOffZero(int i)
-
isDiagonalZero
public boolean isDiagonalZero(int i)
-
resetSteps
public void resetSteps()
-
nextSplit
public boolean nextSplit()
Tells it to process the submatrix at the next split. Should be called after the current submatrix has been processed.
-
performImplicitSingleStep
public void performImplicitSingleStep(double scale, double lambda, boolean byAngle)Given the lambda value perform an implicit QR step on the matrix. B^T*B-lambda*I- Parameters:
lambda- Stepping factor.
-
setSubmatrix
public void setSubmatrix(int x1, int x2)
-
selectWilkinsonShift
public double selectWilkinsonShift(double scale)
Selects the Wilkinson's shift for BTB. See page 410. It is guaranteed to converge and converges fast in practice.- Parameters:
scale- Scale factor used to help prevent overflow/underflow- Returns:
- Shifting factor lambda/(scale*scale)
-
exceptionShift
public void exceptionShift()
It is possible for the QR algorithm to get stuck in a loop because of symmetries. This happens more often with larger matrices. By taking a random step it can break the symmetry and finish.
-
printMatrix
public void printMatrix()
-
getNumberOfSingularValues
public int getNumberOfSingularValues()
-
getSingularValue
public double getSingularValue(int index)
-
setFastValues
public void setFastValues(boolean b)
-
getSingularValues
public double[] getSingularValues()
-
getDiag
public double[] getDiag()
-
getOff
public double[] getOff()
-
getMaxValue
public double getMaxValue()
-
-
DMelt 3.0 © DataMelt by jWork.ORG