def test_gram_schmidt_shape(self): A = np.random.randn(20, 10) V = randomized_svd.gram_schmidt(A) self.assertEqual((20, 10), V.shape) A = np.random.randn(20, 30) V = randomized_svd.gram_schmidt(A) self.assertEqual((20, 30), V.shape)
def test_gram_schmidt_use_start_column2(self): A = np.random.randn(50, 10) Q, R = la.qr(A, mode='economic') Q = np.hstack((Q, np.random.randn(50, 30))) V = randomized_svd.gram_schmidt(Q, start_col=9) self.assertLess((np.eye(40) - V.T.dot(V)).max(), 1e-10)
def test_gram_schmidt_use_start_column(self): A = np.random.randn(50, 5) Q, _ = la.qr(A, mode='economic') A = np.hstack((Q, np.random.randn(50, 5))) V = randomized_svd.gram_schmidt(A, start_col=4) self.assertLess((np.eye(5) - V[:, 5:].T.dot(V[:, 5:])).max(), 1e-10)
def test_gram_schmidt_orthonormal_2(self): A = np.random.randn(100, 100) V = randomized_svd.gram_schmidt(A) self.assertLess((np.eye(100) - V.T.dot(V)).max(), 1e-12)