public void When_Transpose_Q(int size) { // Arrange Random device = new Random(); Matrix A = new Matrix(size, size); Matrix I = new Matrix(size, size); for (int i = 0; i < size; i++) { I.Elem[i][i] = 1; for (int j = 0; j < size; j++) { A.Elem[i][j] = device.NextDouble(); } } Matrix Q1 = new Matrix(A.Row, A.Column); Matrix R1 = new Matrix(A.Row, A.Column); Matrix Q2 = new Matrix(A.Row, A.Column); Matrix R2 = new Matrix(A.Row, A.Column); Matrix Q3 = new Matrix(A.Row, A.Column); Matrix R3 = new Matrix(A.Row, A.Column); for (int i = 0; i < A.Row; i++) { Q3.Elem[i][i] = 1.0; } Matrix Q4 = new Matrix(A.Row, A.Column); Matrix R4 = new Matrix(A.Row, A.Column); for (int i = 0; i < A.Row; i++) { Q4.Elem[i][i] = 1.0; } GramSchmidt.Classic(A, Q1, R1); GramSchmidt.Modified(A, Q2, R2); Givens.Orthogon(A, Q3, R3); Householder.Orthogon(A, Q4, R4); // Act Matrix QT1 = Q1.Transpose(); Matrix QT2 = Q2.Transpose(); Matrix QT3 = Q3.Transpose(); Matrix QT4 = Q4.Transpose(); // Assert Assert.That(QT1 * Q1 == I); Assert.That(QT2 * Q2 == I); Assert.That(QT3 * Q3 == I); Assert.That(QT4 * Q4 == I); }