Class Householder

java.lang.Object
org.flag4j.linalg.transformations.Householder

public final class Householder extends Object
This class contains methods for computing real or complex Householder reflectors (also known as elementary reflectors). A Householder reflector is a transformation matrix which reflects a vector about a hyperplane containing the origin.
  • Method Summary

    Modifier and Type
    Method
    Description
    static CMatrix
    Computes the Householder reflector which describes a reflection through a hyperplane containing the origin which is normal to the specified normal vector.
    static Matrix
    Computes the Householder reflector which describes a reflection through a hyperplane containing the origin which is normal to the specified normal vector.
    static Vector
    getVector(Vector normal)
    Computes the vector v in of a Householder matrix H=I-2vvT where H is a transformation matrix which reflects a vector across the plane normal to normal.
    static void
    hermLeftRightMultReflector(CMatrix src, Complex128[] householderVector, Complex128 alpha, int startCol, Complex128[] workArray)
    Applies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v to a Hermitian matrix A on both the left and right side.
    static void
    leftMultReflector(CMatrix src, Complex128[] householderVector, Complex128 alpha, int startCol, int startRow, int endRow, Complex128[] workArray)
    Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A.
    static void
    leftMultReflector(CMatrix src, CVector householderVector, Complex128 alpha, int startCol, int startRow, int endRow)
    Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A.
    static void
    leftMultReflector(Matrix src, double[] householderVector, double alpha, int startCol, int startRow, int endRow, double[] workArray)
    Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A.
    static void
    leftMultReflector(Matrix src, Vector householderVector, double alpha, int startCol, int startRow, int endRow)
    Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A.
    static void
    rightMultReflector(CMatrix src, Complex128[] householderVector, Complex128 alpha, int startCol, int startRow, int endRow)
    Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A.
    static void
    rightMultReflector(CMatrix src, CVector householderVector, Complex128 alpha, int startCol, int startRow, int endRow)
    Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A.
    static void
    rightMultReflector(Matrix src, double[] householderVector, double alpha, int startCol, int startRow, int endRow)
    Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A.
    static void
    rightMultReflector(Matrix src, Vector householderVector, double alpha, int startCol, int startRow, int endRow)
    Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A.
    static void
    symmLeftRightMultReflector(Matrix src, double[] householderVector, double alpha, int startCol, double[] workArray)
    Applies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v to a symmetric matrix A on both the left and right side.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getReflector

      public static Matrix getReflector(Vector normal)
      Computes the Householder reflector which describes a reflection through a hyperplane containing the origin which is normal to the specified normal vector.
      Parameters:
      normal - The vector normal to the plane the Householder reflector will reflect through.
      Returns:
      A transformation matrix which describes a reflection through a plane containing the origin with the specified normal vector, i.e. a Householder reflector.
    • getVector

      public static Vector getVector(Vector normal)
      Computes the vector v in of a Householder matrix H=I-2vvT where H is a transformation matrix which reflects a vector across the plane normal to normal.

      This method may be used in conjunction with leftMultReflector(Matrix, Vector, double, int, int, int) and rightMultReflector(Matrix, Vector, double, int, int, int) to efficiently apply reflectors. Doing this is O(n^2) while forming the full Householder matrix and performing matrix multiplication is O(n^3)

      Parameters:
      normal - Vector normal to the plane which H reflects across.
      Returns:
      The vector v in of a Householder matrix H=I-2vvT which reflects across a plane normal to normal.
    • getReflector

      public static CMatrix getReflector(CVector normal)
      Computes the Householder reflector which describes a reflection through a hyperplane containing the origin which is normal to the specified normal vector.

      This method may be used in conjunction with leftMultReflector(CMatrix, CVector, Complex128, int, int, int) and rightMultReflector(CMatrix, CVector, Complex128, int, int, int) to efficiently apply reflectors. Doing this is O(n^2) while forming the full Householder matrix and performing matrix multiplication is O(n^3)

      Parameters:
      normal - The vector normal to the plane the Householder reflector will reflect through\.
      Returns:
      A transformation matrix which describes a reflection through a plane containing the origin with the specified normal vector, i.e. a Householder reflector.
    • leftMultReflector

      public static void leftMultReflector(Matrix src, double[] householderVector, double alpha, int startCol, int startRow, int endRow, double[] workArray)
      Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A. That is, computes HT*A = (I-invalid input: '&alpha'vvT)T*A.
      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
      workArray - An array to store temporary column data. This can help both with cache performance and reducing unneeded garbage collection if this method is called repeatedly.
    • rightMultReflector

      public static void rightMultReflector(Matrix src, double[] householderVector, double alpha, int startCol, int startRow, int endRow)
      Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A. That is, computes A*H = A*(I-invalid input: '&alpha'vvT).
      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
    • leftMultReflector

      public static void leftMultReflector(CMatrix src, Complex128[] householderVector, Complex128 alpha, int startCol, int startRow, int endRow, Complex128[] workArray)
      Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A. That is, computes H*A = (I-invalid input: '&alpha'vvH)*A.
      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
      workArray - An array to store temporary column data. This can help both with cache performance and reducing unneeded garbage collection if this method is called repeatedly.
    • rightMultReflector

      public static void rightMultReflector(CMatrix src, Complex128[] householderVector, Complex128 alpha, int startCol, int startRow, int endRow)
      Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A. That is, computes A*H = A*(I-invalid input: '&alpha'vvH).
      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
    • symmLeftRightMultReflector

      public static void symmLeftRightMultReflector(Matrix src, double[] householderVector, double alpha, int startCol, double[] workArray)

      Applies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v to a symmetric matrix A on both the left and right side. That is, computes H*A*H.

      Note: no check is made to explicitly check that the src matrix is actually symmetric.

      Parameters:
      src - Matrix to apply the Householder reflector to. Assumed to be square and symmetric. Upper triangular portion overwritten with the result.
      householderVector - Householder vector v from the definition of a Householder reflector matrix.
      alpha - The scalar invalid input: '&alpha' value in Householder reflector matrix definition.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      workArray - Array for storing temporary values during the computation. Contents will be overwritten.
    • leftMultReflector

      public static void leftMultReflector(Matrix src, Vector householderVector, double alpha, int startCol, int startRow, int endRow)
      Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A. That is, computes H*A = (I-invalid input: '&alpha'vvT)*A.

      This method is significantly more efficient than forming the full Householder matrix and multiplying it to the other matrix.

      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
    • rightMultReflector

      public static void rightMultReflector(Matrix src, Vector householderVector, double alpha, int startCol, int startRow, int endRow)
      Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvT, represented by the vector v, to another matrix A. That is, computes A*H = A*(I-invalid input: '&alpha'vvT).

      This method is significantly more efficient than forming the full Householder matrix and multiplying it to the other matrix.

      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
    • leftMultReflector

      public static void leftMultReflector(CMatrix src, CVector householderVector, Complex128 alpha, int startCol, int startRow, int endRow)
      Left multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A. That is, computes H*A = (I-invalid input: '&alpha'vvH)*A.

      This method is significantly more efficient than forming the full Householder matrix and multiplying it to the other matrix.

      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
    • rightMultReflector

      public static void rightMultReflector(CMatrix src, CVector householderVector, Complex128 alpha, int startCol, int startRow, int endRow)
      Right multiplies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v, to another matrix A. That is, computes A*H = A*(I-invalid input: '&alpha'vvH).

      This method is significantly more efficient than forming the full Householder matrix and multiplying it to the other matrix.

      Parameters:
      src - Source matrix apply Householder vector to (modified).
      householderVector - Householder vector v.
      alpha - Scalar value in Householder matrix.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      startRow - Starting row of sub-matrix in src to apply reflector to.
      endRow - Starting row of sub-matrix in src to apply reflector to.
    • hermLeftRightMultReflector

      public static void hermLeftRightMultReflector(CMatrix src, Complex128[] householderVector, Complex128 alpha, int startCol, Complex128[] workArray)

      Applies a Householder matrix H=I-invalid input: '&alpha'vvH, represented by the vector v to a Hermitian matrix A on both the left and right side. That is, computes H*A*H.

      Note: no check is made to explicitly check that the src matrix is actually Hermitian.

      Parameters:
      src - Matrix to apply the Householder reflector to. Assumed to be square and Hermitian. Upper triangular portion overwritten with the result.
      householderVector - Householder vector v from the definition of a Householder reflector matrix.
      alpha - The scalar invalid input: '&alpha' value in Householder reflector matrix definition.
      startCol - Starting column of sub-matrix in src to apply reflector to.
      workArray - Array for storing temporary values during the computation. Contents will be overwritten.