def test_orthonormalize(self): """Test for orthonormalization with removing non-independent vectors.""" sqrt_half = numpy.sqrt(0.5) expected_array = numpy.array([ [sqrt_half, sqrt_half, 0], [sqrt_half, -sqrt_half, 0], [0, 0, 1], ]) array = numpy.array([[1, 1, 10, 1], [1, -1, 10, 1], [0, 0, 2, 1]], dtype=float) array[:, 0] *= sqrt_half array = orthonormalize(array, 1) self.assertTrue(numpy.allclose(array, expected_array))
def test_orthonormalize_complex(self): """Test for orthonormalization with complex matrix.""" sqrt_half = numpy.sqrt(0.5) expected_array = numpy.array([ [sqrt_half * 1.0j, sqrt_half * 1.0j, 0], [sqrt_half * 1.0j, -sqrt_half * 1.0j, 0], [0, 0, 1], ], dtype=complex) array = numpy.array([[1.j, 1.j, 10], [1.j, -1.j, 10], [0, 0, 2]], dtype=complex) array[:, 0] *= sqrt_half array = orthonormalize(array, 1) self.assertTrue(numpy.allclose(array, expected_array))