public class BlockHouseHolder_FDRB
extends java.lang.Object
Contains various helper functions for performing a block matrix QR decomposition.
Assumptions:
FMatrixRBlock
.
Constructor and Description |
---|
BlockHouseHolder_FDRB() |
Modifier and Type | Method and Description |
---|---|
static void |
add_row(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int rowA,
float alpha,
org.ejml.data.FSubmatrixD1 B,
int rowB,
float beta,
org.ejml.data.FSubmatrixD1 C,
int rowC,
int zeroOffset,
int end) |
static boolean |
computeHouseHolderCol(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
float[] gamma,
int i)
Computes the householder vector that is used to create reflector for the column.
|
static boolean |
computeHouseHolderRow(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
float[] gamma,
int i)
Computes the householder vector from the specified row
|
static float |
computeTauAndDivideCol(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
int col,
float max)
From the specified column of Y tau is computed and each element is divided by 'max'.
|
static float |
computeTauAndDivideRow(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
int row,
int colStart,
float max)
From the specified row of Y tau is computed and each element is divided by 'max'.
|
static void |
computeW_Column(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
org.ejml.data.FSubmatrixD1 W,
float[] temp,
float[] beta,
int betaIndex)
Computes W from the householder reflectors stored in the columns of the column block
submatrix Y.
|
static void |
computeY_t_V(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
int col,
float[] temp)
Computes YTv(j).
|
static void |
computeZ(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
org.ejml.data.FSubmatrixD1 W,
int col,
float[] temp,
float beta)
Computes the vector z and inserts it into 'W':
z = - βj*(Vj + W*h) where h is a vector of length 'col' and was computed using computeY_t_V(int, org.ejml.data.FSubmatrixD1, int, float[]) . |
static boolean |
decomposeQR_block_col(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
float[] gamma)
Performs a standard QR decomposition on the specified submatrix that is one block wide.
|
static void |
divideElementsCol(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
int col,
float val)
Divides the elements at the specified column by 'val'.
|
static float |
findMaxCol(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
int col)
Finds the element in the column with the largest absolute value.
|
static float |
findMaxRow(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
int row,
int colStart)
Finds the element in the column with the largest absolute value.
|
static void |
initializeW(int blockLength,
org.ejml.data.FSubmatrixD1 W,
org.ejml.data.FSubmatrixD1 Y,
int widthB,
float b)
Sets W to its initial value using the first column of 'y' and the value of 'b':
W = -βv where v = Y(:,0). |
static float |
innerProdCol(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int colA,
int widthA,
int colB,
int widthB)
Computes the inner product of column vector 'colA' against column vector 'colB' while taking account leading zeros and one.
ret = aT*b |
static float |
innerProdRow(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int rowA,
org.ejml.data.FSubmatrixD1 B,
int rowB,
int zeroOffset)
Computes the inner product of row vector 'rowA' against row vector 'rowB' while taking account leading zeros and one.
ret = aT*b |
static void |
multAdd_zeros(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
org.ejml.data.FSubmatrixD1 B,
org.ejml.data.FSubmatrixD1 C)
Special multiplication that takes in account the zeros and one in Y, which
is the matrix that stores the householder vectors.
|
static void |
multBlockAdd_zerosone(float[] dataA,
float[] dataB,
float[] dataC,
int indexA,
int indexB,
int indexC,
int heightA,
int widthA,
int widthC)
Inner block mult add operation that takes in account the zeros and on in dataA,
which is the top part of the Y block vector that has the householder vectors.
C = C + A * B |
static void |
multTransA_vecCol(int blockLength,
org.ejml.data.FSubmatrixD1 A,
org.ejml.data.FSubmatrixD1 B,
org.ejml.data.FSubmatrixD1 C)
Performs a matrix multiplication on the block aligned submatrices.
|
protected static void |
multTransABlockSet_lowerTriag(float[] dataA,
float[] dataB,
float[] dataC,
int indexA,
int indexB,
int indexC,
int heightA,
int widthA,
int widthC)
Performs a matrix multiplication on an single inner block where A is assumed to be lower triangular with diagonal
elements equal to 1.
C = A^T * B |
static void |
rank1UpdateMultL_LeftCol(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int row,
float gamma,
int zeroOffset)
Applies a householder reflector stored in row 'row' to the left column block.
|
static void |
rank1UpdateMultL_Row(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int row,
int colStart,
float gamma)
Applies a householder reflector stored in row 'row' to the remainder of the row
in the block after it.
|
static void |
rank1UpdateMultR_Col(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int col,
float gamma)
Applies a householder reflector stored in column 'col' to the remainder of the columns
in the block after it.
|
static void |
rank1UpdateMultR_TopRow(int blockLength,
org.ejml.data.FSubmatrixD1 A,
int col,
float gamma)
Applies a householder reflector stored in column 'col' to the top block row (excluding
the first column) of A.
|
static void |
scale_row(int blockLength,
org.ejml.data.FSubmatrixD1 Y,
org.ejml.data.FSubmatrixD1 W,
int row,
int zeroOffset,
float val)
Scales the elements in the specified row starting at element colStart by 'val'.
W = val*Y Takes in account zeros and leading one automatically. |
public static boolean decomposeQR_block_col(int blockLength, org.ejml.data.FSubmatrixD1 Y, float[] gamma)
blockLength
- Y
- gamma
- public static boolean computeHouseHolderCol(int blockLength, org.ejml.data.FSubmatrixD1 Y, float[] gamma, int i)
Computes the householder vector that is used to create reflector for the column. The results are stored in the original matrix.
The householder vector 'u' is computed as follows:
u(1) = 1
u(i) = x(i)/(τ + x(1))
public static boolean computeHouseHolderRow(int blockLength, org.ejml.data.FSubmatrixD1 Y, float[] gamma, int i)
Computes the householder vector from the specified row
The householder vector 'u' is computed as follows:
u(1) = 1
u(i) = x(i)/(τ + x(1))
public static void rank1UpdateMultR_Col(int blockLength, org.ejml.data.FSubmatrixD1 A, int col, float gamma)
Applies a householder reflector stored in column 'col' to the remainder of the columns
in the block after it. Takes in account leading zeros and one.
A = (I - γ*u*uT)*A
A
- submatrix that is at most one block wide and aligned along inner blockscol
- The column in A containing 'u'public static void rank1UpdateMultR_TopRow(int blockLength, org.ejml.data.FSubmatrixD1 A, int col, float gamma)
Applies a householder reflector stored in column 'col' to the top block row (excluding
the first column) of A. Takes in account leading zeros and one.
A = (I - γ*u*uT)*A
A
- submatrix that is at most one block wide and aligned along inner blockscol
- The column in A containing 'u'public static void rank1UpdateMultL_Row(int blockLength, org.ejml.data.FSubmatrixD1 A, int row, int colStart, float gamma)
Applies a householder reflector stored in row 'row' to the remainder of the row
in the block after it. Takes in account leading zeros and one.
A = A*(I - γ*u*uT)
A
- submatrix that is block alignedrow
- The row in A containing 'u'colStart
- First index in 'u' that the reflector starts atpublic static void rank1UpdateMultL_LeftCol(int blockLength, org.ejml.data.FSubmatrixD1 A, int row, float gamma, int zeroOffset)
Applies a householder reflector stored in row 'row' to the left column block.
Takes in account leading zeros and one.
A = A*(I - γ*u*uT)
A
- submatrix that is block alignedrow
- The row in A containing 'u'zeroOffset
- How far off the diagonal is the first element in 'u'public static float innerProdCol(int blockLength, org.ejml.data.FSubmatrixD1 A, int colA, int widthA, int colB, int widthB)
Computes the inner product of column vector 'colA' against column vector 'colB' while taking account leading zeros and one.
ret = aT*b
Column A is assumed to be a householder vector. Element at 'colA' is one and previous ones are zero.
blockLength
- A
- block aligned submatrix.colA
- Column inside the block of first column vector.widthA
- how wide the column block that colA is inside of.colB
- Column inside the block of second column vector.widthB
- how wide the column block that colB is inside of.public static float innerProdRow(int blockLength, org.ejml.data.FSubmatrixD1 A, int rowA, org.ejml.data.FSubmatrixD1 B, int rowB, int zeroOffset)
Computes the inner product of row vector 'rowA' against row vector 'rowB' while taking account leading zeros and one.
ret = aT*b
Row A is assumed to be a householder vector. Element at 'colStartA' is one and previous elements are zero.
blockLength
- A
- block aligned submatrix.rowA
- Row index inside the sub-matrix of first row vector has zeros and ones..rowB
- Row index inside the sub-matrix of second row vector.public static void add_row(int blockLength, org.ejml.data.FSubmatrixD1 A, int rowA, float alpha, org.ejml.data.FSubmatrixD1 B, int rowB, float beta, org.ejml.data.FSubmatrixD1 C, int rowC, int zeroOffset, int end)
public static void divideElementsCol(int blockLength, org.ejml.data.FSubmatrixD1 Y, int col, float val)
public static void scale_row(int blockLength, org.ejml.data.FSubmatrixD1 Y, org.ejml.data.FSubmatrixD1 W, int row, int zeroOffset, float val)
zeroOffset
- How far off the diagonal is the first element in the vector.public static float computeTauAndDivideCol(int blockLength, org.ejml.data.FSubmatrixD1 Y, int col, float max)
From the specified column of Y tau is computed and each element is divided by 'max'. See code below:
for i=col:Y.numRows Y[i][col] = u[i][col] / max tau = tau + u[i][col]*u[i][col] end tau = sqrt(tau) if( Y[col][col] < 0 ) tau = -tau;
public static float computeTauAndDivideRow(int blockLength, org.ejml.data.FSubmatrixD1 Y, int row, int colStart, float max)
From the specified row of Y tau is computed and each element is divided by 'max'. See code below:
for j=row:Y.numCols Y[row][j] = u[row][j] / max tau = tau + u[row][j]*u[row][j] end tau = sqrt(tau) if( Y[row][row] < 0 ) tau = -tau;
row
- Which row in the block will be processedcolStart
- The first column that computation of tau will start atmax
- used to normalize and prevent buffer over flowpublic static float findMaxCol(int blockLength, org.ejml.data.FSubmatrixD1 Y, int col)
public static float findMaxRow(int blockLength, org.ejml.data.FSubmatrixD1 Y, int row, int colStart)
public static void computeW_Column(int blockLength, org.ejml.data.FSubmatrixD1 Y, org.ejml.data.FSubmatrixD1 W, float[] temp, float[] beta, int betaIndex)
Computes W from the householder reflectors stored in the columns of the column block submatrix Y.
Y = v(1)
W = -β1v(1)
for j=2:r
z = -β(I +WYT)v(j)
W = [W z]
Y = [Y v(j)]
end
where v(.) are the house holder vectors, and r is the block length. Note that
Y already contains the householder vectors so it does not need to be modified.
Y and W are assumed to have the same number of rows and columns.
Y
- Input matrix containing householder vectors. Not modified.W
- Resulting W matrix. Modified.temp
- Used internally. Must have W.numCols elements.beta
- Beta's for householder vectors.betaIndex
- Index of first relevant beta.public static void initializeW(int blockLength, org.ejml.data.FSubmatrixD1 W, org.ejml.data.FSubmatrixD1 Y, int widthB, float b)
Sets W to its initial value using the first column of 'y' and the value of 'b':
W = -βv
where v = Y(:,0).
blockLength
- size of the inner blockW
- Submatrix being initialized.Y
- Contains householder vectorwidthB
- How wide the W block matrix is.b
- betapublic static void computeZ(int blockLength, org.ejml.data.FSubmatrixD1 Y, org.ejml.data.FSubmatrixD1 W, int col, float[] temp, float beta)
computeY_t_V(int, org.ejml.data.FSubmatrixD1, int, float[])
.
V is a column in the Y matrix. Z is a column in the W matrix. Both Z and V are
column 'col'.public static void computeY_t_V(int blockLength, org.ejml.data.FSubmatrixD1 Y, int col, float[] temp)
temp
- Temporary storage of least length 'col'public static void multAdd_zeros(int blockLength, org.ejml.data.FSubmatrixD1 Y, org.ejml.data.FSubmatrixD1 B, org.ejml.data.FSubmatrixD1 C)
public static void multBlockAdd_zerosone(float[] dataA, float[] dataB, float[] dataC, int indexA, int indexB, int indexC, int heightA, int widthA, int widthC)
Inner block mult add operation that takes in account the zeros and on in dataA,
which is the top part of the Y block vector that has the householder vectors.
C = C + A * B
public static void multTransA_vecCol(int blockLength, org.ejml.data.FSubmatrixD1 A, org.ejml.data.FSubmatrixD1 B, org.ejml.data.FSubmatrixD1 C)
Performs a matrix multiplication on the block aligned submatrices. A is
assumed to be block column vector that is lower triangular with diagonal elements set to 1.
C = A^T * B
protected static void multTransABlockSet_lowerTriag(float[] dataA, float[] dataB, float[] dataC, int indexA, int indexB, int indexC, int heightA, int widthA, int widthC)