DebugQR qr = new DebugQR(width,width);
double gamma = 0.2;
double tau = 0.75;
Matrix U = Matrix.createRandom(width, 1);
Matrix A = Matrix.createRandom(width, width);
qr.convertToColumnMajor(A);
// compute the results using standard matrix operations
Matrix I = Matrix.createIdentity(width-w);
// SimpleMatrix u_sub = U.extractMatrix(w,width,0,1);
AStridedMatrix u_sub = U.subMatrix(w, width-w, 0, 1);
u_sub.set(0,0,1);// assumed to be 1 in the algorithm
// SimpleMatrix A_sub = A.extractMatrix(w,width,w,width);
AStridedMatrix A_sub = A.subMatrix(w,width-w,w,width-w);
// SimpleMatrix expected = I.minus(u_sub.mult(u_sub.transpose()).scale(gamma)).mult(A_sub);
Matrix temp1 = Multiplications.multiply(u_sub, u_sub.getTranspose());
temp1.scale(gamma);
I.sub(temp1);
Matrix expected = Multiplications.multiply(I, A_sub);
qr.updateA(w,U.asDoubleArray(),gamma,tau);
double[][] found = qr.getQR();
for( int i = w+1; i < width; i++ ) {
assertEquals(U.get(i,0),found[w][i],1e-8);
}
// the right should be the same
for( int i = w; i < width; i++ ) {
for( int j = w+1; j < width; j++ ) {
double a = expected.get(i-w,j-w);
double b = found[j][i];
assertEquals(a,b,1e-6);
}
}