DebugQR qr = new DebugQR(width,width);
double gamma = 0.2;
double tau = 0.75;
SimpleMatrix U = new SimpleMatrix(width,1);
SimpleMatrix A = new SimpleMatrix(width,width);
RandomMatrices.setRandom(U.getMatrix(),rand);
RandomMatrices.setRandom(A.getMatrix(),rand);
CommonOps.transpose(A.getMatrix(),qr.getQR());
// compute the results using standard matrix operations
SimpleMatrix I = SimpleMatrix.identity(width-w);
SimpleMatrix u_sub = U.extractMatrix(w,width,0,1);
u_sub.set(0,0,1);// assumed to be 1 in the algorithm
SimpleMatrix A_sub = A.extractMatrix(w,width,w,width);
SimpleMatrix expected = I.minus(u_sub.mult(u_sub.transpose()).scale(gamma)).mult(A_sub);
qr.updateA(w,U.getMatrix().getData(),gamma,tau);
DenseMatrix64F found = qr.getQR();
for( int i = w+1; i < width; i++ ) {
assertEquals(U.get(i,0),found.get(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.get(j,i);
assertEquals(a,b,1e-6);
}
}