}
private void checkDecomposition(int height, int width, boolean compact ) {
QRDecomposition alg = createQRDecomposition(compact);
Matrix A = Matrix.createRandom(height, width);
IQRResult result = alg.decompose(A);
assertNotNull(result);
int minStride = Math.min(height,width);
Matrix Q = result.getQ().toMatrix();
Matrix R = result.getR().toMatrix();
assertTrue(Q.rowCount() == height && Q.columnCount() == height);
assertTrue(R.rowCount() == (compact ? minStride : height));
assertTrue(R.columnCount() == width);
// see if Q has the expected properties
assertTrue(Q.isOrthogonal(1e-8));
// see if it has the expected properties
R = R.reshape(A.rowCount(), A.columnCount());
Matrix A_found = Multiplications.multiply(Q, R);
A.epsilonEquals(A_found,1e-6);
assertTrue(Multiplications.multiply(Q.getTranspose(),A).epsilonEquals(R,1e-6));
}