numericalMethods.algebra.linear.decompose
Class Householder

java.lang.Object
  |
  +--numericalMethods.algebra.linear.decompose.Householder

public class Householder
extends java.lang.Object

Computes for a matrix A the matrices Q and R complying A=QR. The algorithm used is the Householder algorithm.

Advantages
Always good-natured
Few additional resources
Works on non-square matrices (more rows than columns)
Gives determinant
Disadvantages
Not very fast

This algorithm is implemented for both real and complex valued equation systems. And each method is again available in three versions.

One version is an optimized version that consumes as few resources as possible. Moreover it is possible to pass objects that this method can store temporary results during computation in them. This is for example useful when calling this method multiple times so there is no need for this method to allocate memory again and again. If null is passed for the temporary objects then suitable objects are allocated by the method itself.

The third version is an easy to use version that takes care of for example not changing any arguments where not expected. But this version can sometimes be very resource consuming!

The second version is kind of a mix between the first and the third version giving the orthogonal and triangular matrix while destroying the original matrix. Additionally it is possible to reduce the number of columns of the orthogonal matrix so that only some leading orthonormal vectors are given back.

Method versions for decompose:

optimizedsemi optimizedeasy to use
real valued decompose(A,d,...) decompose(A,Q,...) decompose(A,Q,R)
complex valued decompose(A,d,...) decompose(A,Q,...) decompose(A,Q,R)
This class does not check any arguments for validity!
For identical arguments results are undefined!

See Also:
numericalMethods.algebra.linear.decompose

Constructor Summary
Householder()
           
 
Method Summary
static double decompose(double[][] A, double[][] Q, double[][] R)
          Decomposes a real matrix.
static double[] decompose(double[][] A_re, double[][] A_im, double[][] Q_re, double[][] Q_im, double[][] R_re, double[][] R_im)
          Decomposes a complex matrix.
static double[] decompose(double[][] A_re, double[][] A_im, double[][] Q_re, double[][] Q_im, double[] t0, double[] t1, double[] t2, double[] t3)
          Decomposes a complex matrix while separating the orthogonal matrix.
static double decompose(double[][] A, double[][] Q, double[] t0, double[] t1)
          Decomposes a real matrix while separating the orthogonal matrix.
static double[] decompose(double[][] A_re, double[][] A_im, double[] d_re, double[] d_im, double[] t0, double[] t1)
          Decomposes a complex matrix storing the result in a merged way.
static double decompose(double[][] A, double[] d, double[] t)
          Decomposes a real matrix storing the result in a merged way.
static void qTimes(double[][] Q, double[][] A, boolean conj, double[] t)
          Computes the product of a matrix with the producing vectors of an orthogonal matrix and a matrix.
static void qTimes(double[][] Q_re, double[][] Q_im, double[][] A_re, double[][] A_im, boolean conj, double[] t0, double[] t1)
          Computes the product of a matrix with the producing vectors of an unitary matrix with a matrix.
static void qTimes(double[][] Q_re, double[][] Q_im, double[] a_re, double[] a_im, boolean conj)
          Computes the product of a matrix with the producing vectors of an unitary matrix with a vector.
static void qTimes(double[][] Q, double[] a, boolean conj)
          Computes the product of a matrix with the producing vectors of an orthogonal matrix and a vector.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Householder

public Householder()
Method Detail

decompose

public static double decompose(double[][] A,
                               double[] d,
                               double[] t)
Decomposes a real matrix storing the result in a merged way.

After decomposition the matrix contains the merged right triangular matrix and the producing vectors of the orthogonal matrix. The diagonal belongs to the orthogonal matrix and the diagonal of the right triangular matrix is stored in an extra vector.

For multiplying the orthogonal matrix Q stored by its producing vectors with another matrix A the method qTimes can be used:

QA ≡ qTimes(Q,A,false,null)
QTA ≡ qTimes(Q,A,true,null)

Parameters:
A - The matrix to decompose and afterwards the merged producing vectors of the orthogonal matrix and of the right triangular matrix.
d - The diagonal of the right triangular matrix.
t - A double array of same length as the matrix has columns for storing temporary results during the computation.
Returns:
a double with det(A)
See Also:
qTimes

decompose

public static double decompose(double[][] A,
                               double[][] Q,
                               double[] t0,
                               double[] t1)
Decomposes a real matrix while separating the orthogonal matrix.

Parameters:
A - The matrix to decompose and afterwards the right triangular matrix.
Q - A matrix taking (a part of) the orthogonal matrix. If one doesn't want all orthonormal vectors it is possible to pass a matrix beeing not square. That is still having as much rows as A but having possibly less columns.
t0 - A double array of same length as the matrix has columns for storing temporary results during the computation.
t1 - A double array of same length as the matrix has rows for storing temporary results during the computation.
Returns:
a double with det(A)

decompose

public static double decompose(double[][] A,
                               double[][] Q,
                               double[][] R)
Decomposes a real matrix.

This method temporary allocates:

Parameters:
A - The matrix to decompose.
Q - A matrix taking the orthogonal matrix. It must be square and must have the same number of rows as A has.
R - A matrix taking the right triangular matrix. It must have the same number of rows and columns as A has.
Returns:
a double with det(A)

decompose

public static double[] decompose(double[][] A_re,
                                 double[][] A_im,
                                 double[] d_re,
                                 double[] d_im,
                                 double[] t0,
                                 double[] t1)
Decomposes a complex matrix storing the result in a merged way.

After decomposition the matrix contains the merged right triangular matrix and the producing vectors of the unitary matrix. The diagonal belongs to the unitary matrix and the diagonal of the right triangular matrix is stored in an extra vector.

For multiplying the unitary matrix Q stored by its producing vectors with another matrix A the method qTimes can be used:

QA ≡ qTimes(Qre,Qim,Are,Aim,false,null,null)
QA ≡ qTimes(Qre,Qim,Are,Aim,true,null,null)
(Note: Q means transposed and conjugated.)
Parameters:
A_re - The real part of the matrix to decompose and afterwards the real parts of the merged producing vectors of the unitary matrix and of the right triangular matrix.
A_im - The imaginary part of the matrix to decompose and afterwards the imaginary parts of the merged producing vectors of the unitary matrix and of the right triangular matrix.
d_re - The real part of the diagonal of the right triangular matrix.
d_im - The imaginary part of the diagonal of the right triangular matrix.
t0 - A double array of same length as the matrix has columns for storing temporary results during the computation.
t1 - A double array of same length as the matrix has columns for storing temporary results during the computation.
Returns:
a double[] with det(A)
See Also:
qTimes

decompose

public static double[] decompose(double[][] A_re,
                                 double[][] A_im,
                                 double[][] Q_re,
                                 double[][] Q_im,
                                 double[] t0,
                                 double[] t1,
                                 double[] t2,
                                 double[] t3)
Decomposes a complex matrix while separating the orthogonal matrix.

Parameters:
A_re - The real part of the matrix to decompose and afterwards the real part of the right triangular matrix.
A_im - The imaginary part of the matrix to decompose and afterwards the imaginary part of the right triangular matrix.
Q_re - A matrix taking (a part of) the real part of the unitary matrix. If one doesn't want all orthonormal vectors it is possible to pass a matrix beeing not square. That is still having as much rows as A but having possibly less columns.
Q_im - A matrix taking (a part of) the imaginary part of the unitary matrix. If one doesn't want all orthonormal vectors it is possible to pass a matrix beeing not square. That is still having as much rows as A but having possibly less columns.
t0 - A double array of same length as the matrix has columns for storing temporary results during the computation.
t1 - A double array of same length as the matrix has columns for storing temporary results during the computation.
t2 - A double array of same length as the matrix has rows for storing temporary results during the computation.
t3 - A double array of same length as the matrix has rows for storing temporary results during the computation.
Returns:
a double[] with det(A)

decompose

public static double[] decompose(double[][] A_re,
                                 double[][] A_im,
                                 double[][] Q_re,
                                 double[][] Q_im,
                                 double[][] R_re,
                                 double[][] R_im)
Decomposes a complex matrix.

This method temporary allocates:

Parameters:
A_re - The real part of the matrix to decompose.
A_im - The imaginary part of the matrix to decompose.
Q_re - The real part of a matrix taking the unitary matrix. It must be square and must have the same number of rows as A has.
Q_im - The imaginary part of a matrix taking the unitary matrix. It must be square and must have the same number of rows as A has.
R_re - The real part of a matrix taking the right triangular matrix. It must have the same number of rows and columns as A has.
R_im - The imaginary part of a matrix taking the right triangular matrix. It must have the same number of rows and columns as A has.
Returns:
a double[] with det(A)

qTimes

public static void qTimes(double[][] Q,
                          double[] a,
                          boolean conj)
Computes the product of a matrix with the producing vectors of an orthogonal matrix and a vector.

Parameters:
Q - The matrix with the producing vectors of the orthogonal matrix.
a - A vector to be multiplied with and afterwards the result.
conj - If false compute Qa and if true QTa.
See Also:
decompose

qTimes

public static void qTimes(double[][] Q_re,
                          double[][] Q_im,
                          double[] a_re,
                          double[] a_im,
                          boolean conj)
Computes the product of a matrix with the producing vectors of an unitary matrix with a vector.

Parameters:
Q_re - The real part of the matrix with the producing vectors of the unitary matrix.
Q_im - The imaginary part of the matrix with the producing vectors of the unitary matrix.
a_re - The real part of a vector to be multiplied with and afterwards the result.
a_im - The imaginary part of a vector to be multiplied with and afterwards the result.
conj - If false compute Qa and if true Qa.
(Note: Q means transposed and conjugated.)
See Also:
decompose

qTimes

public static void qTimes(double[][] Q,
                          double[][] A,
                          boolean conj,
                          double[] t)
Computes the product of a matrix with the producing vectors of an orthogonal matrix and a matrix.

Parameters:
Q - The matrix with the producing vectors of the orthogonal matrix.
A - A matrix to be multiplied with and afterwards the result.
conj - If false compute QA and if true QTA.
t - A double array of same length as the matrix A has columns for storing temporary results during the computation.
See Also:
decompose

qTimes

public static void qTimes(double[][] Q_re,
                          double[][] Q_im,
                          double[][] A_re,
                          double[][] A_im,
                          boolean conj,
                          double[] t0,
                          double[] t1)
Computes the product of a matrix with the producing vectors of an unitary matrix with a matrix.

Parameters:
Q_re - The real part of the matrix with the producing vectors of the unitary matrix.
Q_im - The imaginary part of the matrix with the producing vectors of the unitary matrix.
A_re - The real part of a matrix to be multiplied with and afterwards the result.
A_im - The imaginary part of a matrix to be multiplied with and afterwards the result.
conj - If false compute QA and if true QA.
(Note: Q means transposed and conjugated.)
t0 - A double array of same length as the matrix A has columns for storing temporary results during the computation.
t1 - A double array of same length as the matrix A has columns for storing temporary results during the computation.
See Also:
decompose