public class SvdImplicitQrAlgorithm_DDRM
extends java.lang.Object
Computes 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-411
Note: To watch it process the matrix step by step uncomment commented out code.
Modifier and Type | Field and Description |
---|---|
protected double[] |
diag |
protected EigenvalueSmall_F64 |
eigenSmall |
protected double |
maxValue |
protected int |
N |
protected int |
nextExceptional |
protected int |
numExceptional |
protected int |
numSplits |
protected double[] |
off |
protected java.util.Random |
rand |
protected int[] |
splits |
protected int |
totalSteps |
protected org.ejml.data.DMatrixRMaj |
Ut |
protected org.ejml.data.DMatrixRMaj |
Vt |
protected int |
x1 |
protected int |
x2 |
Constructor and Description |
---|
SvdImplicitQrAlgorithm_DDRM() |
SvdImplicitQrAlgorithm_DDRM(boolean fastValues) |
Modifier and Type | Method and Description |
---|---|
boolean |
_process() |
protected boolean |
checkForAndHandleZeros()
Checks to see if either the diagonal element or off diagonal element is zero.
|
protected void |
computeRotator(double rise,
double run)
Computes a rotator that will set run to zero (?)
|
protected void |
createBulge(int x1,
double p,
double scale,
boolean byAngle)
Performs a similar transform on BTB-pI
|
protected void |
eigenBB_2x2(int x1)
Computes the eigenvalue of the 2 by 2 matrix BTB
|
void |
exceptionShift()
It is possible for the QR algorithm to get stuck in a loop because of symmetries.
|
double[] |
getDiag() |
double |
getMaxValue() |
int |
getNumberOfSingularValues() |
double[] |
getOff() |
double |
getSingularValue(int index) |
double[] |
getSingularValues() |
org.ejml.data.DMatrixRMaj |
getUt() |
org.ejml.data.DMatrixRMaj |
getVt() |
void |
incrementSteps() |
void |
initParam(int M,
int N) |
boolean |
isDiagonalZero(int i) |
boolean |
isOffZero(int i) |
boolean |
nextSplit()
Tells it to process the submatrix at the next split.
|
void |
performImplicitSingleStep(double scale,
double lambda,
boolean byAngle)
Given the lambda value perform an implicit QR step on the matrix.
|
void |
printMatrix() |
boolean |
process() |
boolean |
process(double[] values)
Perform a sequence of steps based off of the singular values provided.
|
protected void |
removeBulgeLeft(int x1,
boolean notLast) |
protected void |
removeBulgeRight(int x1) |
void |
resetSteps() |
double |
selectWilkinsonShift(double scale)
Selects the Wilkinson's shift for BTB.
|
void |
setFastValues(boolean b) |
void |
setMatrix(int numRows,
int numCols,
double[] diag,
double[] off) |
void |
setMaxValue(double maxValue) |
void |
setSubmatrix(int x1,
int x2) |
void |
setUt(org.ejml.data.DMatrixRMaj ut) |
void |
setVt(org.ejml.data.DMatrixRMaj vt) |
double[] |
swapDiag(double[] diag) |
double[] |
swapOff(double[] off) |
protected void |
updateRotator(org.ejml.data.DMatrixRMaj Q,
int m,
int n,
double c,
double s)
Multiplied a transpose orthogonal matrix Q by the specified rotator.
|
protected java.util.Random rand
protected org.ejml.data.DMatrixRMaj Ut
protected org.ejml.data.DMatrixRMaj Vt
protected int totalSteps
protected double maxValue
protected int N
protected EigenvalueSmall_F64 eigenSmall
protected int numExceptional
protected int nextExceptional
protected double[] diag
protected double[] off
protected int x1
protected int x2
protected int[] splits
protected int numSplits
public SvdImplicitQrAlgorithm_DDRM(boolean fastValues)
public SvdImplicitQrAlgorithm_DDRM()
public org.ejml.data.DMatrixRMaj getUt()
public void setUt(org.ejml.data.DMatrixRMaj ut)
public org.ejml.data.DMatrixRMaj getVt()
public void setVt(org.ejml.data.DMatrixRMaj vt)
public void setMatrix(int numRows, int numCols, double[] diag, double[] off)
public double[] swapDiag(double[] diag)
public double[] swapOff(double[] off)
public void setMaxValue(double maxValue)
public void initParam(int M, int N)
public boolean process()
public boolean process(double[] values)
values
- public boolean _process()
public void incrementSteps()
public boolean isOffZero(int i)
public boolean isDiagonalZero(int i)
public void resetSteps()
public boolean nextSplit()
public void performImplicitSingleStep(double scale, double lambda, boolean byAngle)
lambda
- Stepping factor.protected void updateRotator(org.ejml.data.DMatrixRMaj Q, int m, int n, double c, double s)
Q
- Orthogonal matrixm
- Coordinate of rotator.n
- Coordinate of rotator.c
- cosine of rotator.s
- sine of rotator.protected void createBulge(int x1, double p, double scale, boolean byAngle)
protected void computeRotator(double rise, double run)
protected void removeBulgeLeft(int x1, boolean notLast)
protected void removeBulgeRight(int x1)
public void setSubmatrix(int x1, int x2)
public double selectWilkinsonShift(double scale)
scale
- Scale factor used to help prevent overflow/underflowprotected void eigenBB_2x2(int x1)
protected boolean checkForAndHandleZeros()
public void exceptionShift()
public void printMatrix()
public int getNumberOfSingularValues()
public double getSingularValue(int index)
public void setFastValues(boolean b)
public double[] getSingularValues()
public double[] getDiag()
public double[] getOff()
public double getMaxValue()