public class QrHelperFunctions_CD64
extends java.lang.Object
Contains different functions that are useful for computing the QR decomposition of a matrix.
Two different families of functions are provided for help in computing reflectors. Internally both of these functions switch between normalization by division or multiplication. Multiplication is most often significantly faster than division (2 or 3 times) but produces less accurate results on very small numbers. It checks to see if round off error is significant and decides which one it should do.
Tests were done using the stability benchmark in jmatbench and there doesn't seem to be any advantage to always dividing by the max instead of checking and deciding. The most noticeable difference between the two methods is with very small numbers.
| Constructor and Description |
|---|
QrHelperFunctions_CD64() |
| Modifier and Type | Method and Description |
|---|---|
static double |
computeTauGammaAndDivide(int start,
int stop,
double[] x,
double max,
org.ejml.data.Complex64F tau)
Performs the following operations:
|
static void |
divideElements(int j,
int numRows,
double[] u,
int startU,
double realA,
double imagA)
Performs the following operation:
u[(startU+j):(startU+numRows)] /= A were u and A are a complex |
static double |
findMax(double[] u,
int startU,
int length)
Returns the maximum magnitude of the complex numbers
|
static void |
rank1UpdateMultL(org.ejml.data.CDenseMatrix64F A,
double[] u,
double gammaR,
double gammaI,
int colA0,
int w0,
int w1)
Performs a rank-1 update operation on the submatrix specified by w with the multiply on the left.
A = A(I - γ*u*uH) |
static void |
rank1UpdateMultR(org.ejml.data.CDenseMatrix64F A,
double[] u,
int offsetU,
double gammaR,
int colA0,
int w0,
int w1,
double[] _temp)
Performs a rank-1 update operation on the submatrix specified by w with the multiply on the right.
A = (I - γ*u*uH)*A |
public static double findMax(double[] u,
int startU,
int length)
u - Array of complex numbersstartU - first index to consider in ulength - Number of complex numebrs to considerpublic static void divideElements(int j,
int numRows,
double[] u,
int startU,
double realA,
double imagA)
public static double computeTauGammaAndDivide(int start,
int stop,
double[] x,
double max,
org.ejml.data.Complex64F tau)
x = x / max tau = x0*|x|/|xo| adjust sign to avoid cancelation u = x; u0 = x0 + tau; u = u/u0 (x is not divided by x0) gamma = 2/|u|^2Note that u is not explicitly computed here.
start - Element in 'u' that it starts at.stop - Element in 'u' that it stops at.x - Arraymax - Max value in 'u' that is used to normalize it.tau - Storage for taupublic static void rank1UpdateMultR(org.ejml.data.CDenseMatrix64F A,
double[] u,
int offsetU,
double gammaR,
int colA0,
int w0,
int w1,
double[] _temp)
Performs a rank-1 update operation on the submatrix specified by w with the multiply on the right.
A = (I - γ*u*uH)*A
A - matrixu - vectoroffsetU - offset added to w0 when indexing u. Multiplied by 2 since complex.gammaR - real component of gammacolA0 - first column in A sub-matrix.w0 - first index in sub-array in u and row sub-matrix in Aw1 - last index + 1 in sub-array in u and row sub-matrix in A_temp - temporary storage. Same size as u.public static void rank1UpdateMultL(org.ejml.data.CDenseMatrix64F A,
double[] u,
double gammaR,
double gammaI,
int colA0,
int w0,
int w1)
Performs a rank-1 update operation on the submatrix specified by w with the multiply on the left.
A = A(I - γ*u*uH)
The order that matrix multiplies are performed has been carefully selected to minimize the number of operations.
Before this can become a truly generic operation the submatrix specification needs to be made more generic.