org.ejml.alg.dense.decomposition.qr
Class QRColPivDecompositionHouseholderColumn

java.lang.Object
  extended by org.ejml.alg.dense.decomposition.qr.QRDecompositionHouseholderColumn
      extended by org.ejml.alg.dense.decomposition.qr.QRColPivDecompositionHouseholderColumn
All Implemented Interfaces:
DecompositionInterface<DenseMatrix64F>, QRDecomposition<DenseMatrix64F>, QRPDecomposition<DenseMatrix64F>

public class QRColPivDecompositionHouseholderColumn
extends QRDecompositionHouseholderColumn
implements QRPDecomposition<DenseMatrix64F>

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 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.

Author:
Peter Abeles

Field Summary
protected  double maxAbs
           
protected  double[] normsCol
           
protected  int[] pivots
           
protected  int rank
           
protected  double singularThreshold
           
 
Fields inherited from class org.ejml.alg.dense.decomposition.qr.QRDecompositionHouseholderColumn
dataQR, error, gamma, gammas, minLength, numCols, numRows, tau, v
 
Constructor Summary
QRColPivDecompositionHouseholderColumn()
           
QRColPivDecompositionHouseholderColumn(double singularThreshold)
          Configure parameters.
 
Method Summary
 boolean decompose(DenseMatrix64F A)
           To decompose the matrix 'A' it must have full rank.
 DenseMatrix64F getPivotMatrix(DenseMatrix64F P)
           
 int[] getPivots()
           
 DenseMatrix64F getQ(DenseMatrix64F 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)
           
 
Methods inherited from class org.ejml.alg.dense.decomposition.qr.QRDecompositionHouseholderColumn
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.alg.dense.decomposition.QRDecomposition
getR
 
Methods inherited from interface org.ejml.alg.dense.decomposition.DecompositionInterface
inputModified
 

Field Detail

pivots

protected int[] pivots

normsCol

protected double[] normsCol

maxAbs

protected double maxAbs

singularThreshold

protected double singularThreshold

rank

protected int rank
Constructor Detail

QRColPivDecompositionHouseholderColumn

public QRColPivDecompositionHouseholderColumn(double singularThreshold)
Configure parameters.

Parameters:
singularThreshold - Specify the threshold that selects if column is singular or not. Typically around EPS

QRColPivDecompositionHouseholderColumn

public QRColPivDecompositionHouseholderColumn()
Method Detail

setExpectedMaxSize

public void setExpectedMaxSize(int numRows,
                               int numCols)
Overrides:
setExpectedMaxSize in class QRDecompositionHouseholderColumn

getQ

public DenseMatrix64F getQ(DenseMatrix64F Q,
                           boolean compact)
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 interface QRDecomposition<DenseMatrix64F>
Overrides:
getQ in class QRDecompositionHouseholderColumn
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

public boolean decompose(DenseMatrix64F A)

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 interface DecompositionInterface<DenseMatrix64F>
Overrides:
decompose in class QRDecompositionHouseholderColumn
Parameters:
A - The matrix which is being decomposed. Modification is implementation dependent.
Returns:
Returns if it was able to decompose the matrix.

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 interface QRPDecomposition<DenseMatrix64F>
Returns:
Matrix's rank

getPivots

public int[] getPivots()
Specified by:
getPivots in interface QRPDecomposition<DenseMatrix64F>

getPivotMatrix

public DenseMatrix64F getPivotMatrix(DenseMatrix64F P)
Specified by:
getPivotMatrix in interface QRPDecomposition<DenseMatrix64F>


Copyright © 2012. All Rights Reserved.