# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.operation.householder

## Class HouseholderReflection

• java.lang.Object
• com.numericalmethod.suanshu.algebra.linear.matrix.doubles.operation.householder.HouseholderReflection
• Direct Known Subclasses:
Householder4SubVector, Householder4ZeroGenerator

public class HouseholderReflection
extends Object
A Householder transformation in the 3-dimensional space is the reflection of a vector in the plane. The plane, containing the origin, is uniquely defined by a unit vector, called the defining vector, orthogonal to the plane. The reflection Hx can be computed without explicitly expanding H.

H = I - 2vv'
Hx = (I - 2vv')x = Ix - 2vv'x = x - 2v<v,x>, where x is a column vector
yH = (H'y')' = (Hy')', where y is a row vector

When H is applied to a set of column vectors, it transforms each vector individually, as in block matrix multiplication.

H * A = H * [A1 A2 ... An] = [H * A1 H *
A2 ... H * An]

When H is applied to a set of row vectors, it transforms each vector individually, as in block matrix multiplication. $AH = \begin{bmatrix} A_1H\\ A_2H\\ A_3H\\ A_4H\\ A_5H \end{bmatrix}$
• ### Constructor Summary

Constructors
Constructor and Description
HouseholderReflection(HouseholderContext ctx)
HouseholderReflection(Vector v)
Construct a Householder matrix from the vector that defines the hyperplane orthogonal to the vector.
HouseholderReflection(Vector v, double beta, double lambda)
• ### Method Summary

All Methods
Modifier and Type Method and Description
Vector definingVector()
Get the Householder defining vector which is orthogonal to the Householder hyperplane.
Matrix H()
Get the Householder matrix H = I - 2 * v * v'.
static Matrix product(HouseholderReflection[] Hs, int from, int to)
Compute Q from Householder matrices {Qi}.
static Matrix product(HouseholderReflection[] Hs, int from, int to, int nRows, int nCols)
Compute Q from Householder matrices {Qi}.
Matrix reflect(Matrix A)
Apply the Householder matrix, H, to a matrix (a set of column vectors), A.
Vector reflect(Vector x)
Apply the Householder matrix, H, to a column vector, x.
Matrix reflectColumns(Matrix A)
Matrix reflectRows(Matrix A)
void reflectVectors(Vector[] vectors, int startIndex, int endIndex)
Apply the Householder matrix, H, to an array of vectors.
Matrix rightReflect(Matrix A)
Apply the Householder matrix, H, to a matrix (a set of row vectors), A.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### HouseholderReflection

public HouseholderReflection(Vector v)
Construct a Householder matrix from the vector that defines the hyperplane orthogonal to the vector. If the defining vector is a 0-vector, the Householder matrix is the identity matrix.
Parameters:
v - the hyperplane defining vector
• #### HouseholderReflection

public HouseholderReflection(HouseholderContext ctx)
• #### HouseholderReflection

public HouseholderReflection(Vector v,
double beta,
double lambda)
• ### Method Detail

• #### definingVector

public Vector definingVector()
Get the Householder defining vector which is orthogonal to the Householder hyperplane.
Returns:
the Householder defining vector
• #### reflect

public Vector reflect(Vector x)
Apply the Householder matrix, H, to a column vector, x.

Hx = x - 2 * <v,x> * v

Parameters:
x - a vector
Returns:
Hx
• #### reflectVectors

public void reflectVectors(Vector[] vectors,
int startIndex,
int endIndex)
Apply the Householder matrix, H, to an array of vectors.
Parameters:
vectors - an array of vectors
startIndex - the start index of the array to apply
endIndex - the end index of the array to apply, inclusive
• #### reflect

public Matrix reflect(Matrix A)
Apply the Householder matrix, H, to a matrix (a set of column vectors), A.

H * A = [H * A1 H * A2 ... H * An]

Parameters:
A - a matrix
Returns:
H * A
• #### reflectColumns

public Matrix reflectColumns(Matrix A)
• #### rightReflect

public Matrix rightReflect(Matrix A)
Apply the Householder matrix, H, to a matrix (a set of row vectors), A. $AH = \begin{bmatrix} A_1H\\ A_2H\\ A_3H\\ A_4H\\ A_5H \end{bmatrix}$
Parameters:
A - a matrix
Returns:
A * H
• #### reflectRows

public Matrix reflectRows(Matrix A)
• #### H

public Matrix H()
Get the Householder matrix H = I - 2 * v * v'. To compute H *v, do not use this method. Instead use reflect(Vector).
Returns:
the Householder matrix
• #### product

public static Matrix product(HouseholderReflection[] Hs,
int from,
int to)
Compute Q from Householder matrices {Qi}.

Q = Q1 * Q2 * ... * Qn * I

This implementation use an efficient way to compute Q, i.e., by applying Qi's repeatedly on an identity matrix.
Parameters:
Hs - an array of Householders
from - the beginning index of H's; Q1 is Qfrom
to - the ending index of H's; Qn is Qto
Returns:
the product of an array of Householder matrices, from Hs[from] to Hs[to]
• #### product

public static Matrix product(HouseholderReflection[] Hs,
int from,
int to,
int nRows,
int nCols)
Compute Q from Householder matrices {Qi}.

Q = Q1 * Q2 * ... * Qn * I

The identity matrix, I, may have more rows than columns. The bottom rows are padded with zeros.

This implementation use an efficient way to compute Q, i.e., by applying Qi's repeatedly on an identity matrix.

Parameters:
Hs - an array of Householders
from - the beginning index of H's; Q1 is Qfrom
to - the ending index of H's; Qn is Qto
nRows - the number of rows of I
nCols - the number of columns of I
Returns:
the product of an array of Householder matrices, from Hs[from] to Hs[to]