Class HouseholderReflection
- java.lang.Object
-
- dev.nm.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.
When H is applied to a set of column vectors, it transforms each vector individually, as in block matrix multiplication.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 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} \]H * A = H * [A1 A2 ... An] = [H * A1 H * A2 ... H * An]
-
-
Constructor Summary
Constructors Constructor 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 Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
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 vectorsstartIndex
- the start index of the array to applyendIndex
- 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
-
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
-
H
public Matrix H()
Get the Householder matrix H = I - 2 * v * v'. To compute H *v, do not use this method. Instead usereflect(Vector)
.- Returns:
- the Householder matrix
-
product
public static Matrix product(HouseholderReflection[] Hs, int from, int to)
Compute Q from Householder matrices {Qi}.
This implementation use an efficient way to compute Q, i.e., by applying Qi's repeatedly on an identity matrix.Q = Q1 * Q2 * ... * Qn * I
- Parameters:
Hs
- an array of Householdersfrom
- the beginning index of H's; Q1 is Qfromto
- the ending index of H's; Qn is Qto- Returns:
- the product of an array of Householder matrices, from
Hs[from]
toHs[to]
-
product
public static Matrix product(HouseholderReflection[] Hs, int from, int to, int nRows, int nCols)
Compute Q from Householder matrices {Qi}.
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.Q = Q1 * Q2 * ... * Qn * I
- Parameters:
Hs
- an array of Householdersfrom
- the beginning index of H's; Q1 is Qfromto
- the ending index of H's; Qn is QtonRows
- the number of rows of InCols
- the number of columns of I- Returns:
- the product of an array of Householder matrices, from
Hs[from]
toHs[to]
-
-