Ejemplo n.º 1
0
 def test_rand(self):
     # Just make sure that things generated are on the manifold and that
     # if you generate two they are not equal.
     X = self.man.rand()
     np_testing.assert_allclose(multiprod(multitransp(X), X), multieye(self.k, self.n), atol=1e-10)
     Y = self.man.rand()
     assert np.linalg.norm(X - Y) > 1e-6
Ejemplo n.º 2
0
 def test_rand(self):
     # Just make sure that things generated are on the manifold and that
     # if you generate two they are not equal.
     X = self.man.rand()
     np_testing.assert_allclose(multiprod(multitransp(X), X),
                                multieye(self.k, self.n), atol=1e-10)
     Y = self.man.rand()
     assert np.linalg.norm(X - Y) > 1e-6
Ejemplo n.º 3
0
 def test_random_point(self):
     # Just make sure that things generated are on the manifold and that
     # if you generate two they are not equal.
     X = self.manifold.random_point()
     np_testing.assert_allclose(multihconj(X) @ X,
                                multieye(self.k, self.n),
                                atol=1e-10)
     Y = self.manifold.random_point()
     assert np.linalg.norm(X - Y) > 1e-6
     assert np.iscomplex(X).all()
Ejemplo n.º 4
0
    def test_exp(self):
        # Check that exp lies on the manifold and that exp of a small vector u
        # is close to x + u.
        s = self.man
        x = s.rand()
        u = s.randvec(x)

        xexpu = s.exp(x, u)
        np_testing.assert_allclose(multiprod(multitransp(xexpu), xexpu), multieye(self.k, self.n), atol=1e-10)

        u = u * 1e-6
        xexpu = s.exp(x, u)
        np_testing.assert_allclose(xexpu, x + u)
Ejemplo n.º 5
0
    def test_retr(self):
        # Test that the result is on the manifold and that for small
        # tangent vectors it has little effect.
        x = self.man.rand()
        u = self.man.randvec(x)

        xretru = self.man.retr(x, u)

        np_testing.assert_allclose(multiprod(multitransp(xretru), xretru), multieye(self.k, self.n), atol=1e-10)

        u = u * 1e-6
        xretru = self.man.retr(x, u)
        np_testing.assert_allclose(xretru, x + u)
Ejemplo n.º 6
0
    def test_exp(self):
        # Check that exp lies on the manifold and that exp of a small vector u
        # is close to x + u.
        s = self.man
        x = s.rand()
        u = s.randvec(x)

        xexpu = s.exp(x, u)
        np_testing.assert_allclose(multiprod(multitransp(xexpu), xexpu),
                                   multieye(self.k, self.n), atol=1e-10)

        u = u * 1e-6
        xexpu = s.exp(x, u)
        np_testing.assert_allclose(xexpu, x + u)
Ejemplo n.º 7
0
    def test_retr(self):
        # Test that the result is on the manifold and that for small
        # tangent vectors it has little effect.
        x = self.man.rand()
        u = self.man.randvec(x)

        xretru = self.man.retr(x, u)

        np_testing.assert_allclose(multiprod(multitransp(xretru), xretru),
                                   multieye(self.k, self.n),
                                   atol=1e-10)

        u = u * 1e-6
        xretru = self.man.retr(x, u)
        np_testing.assert_allclose(xretru, x + u)
Ejemplo n.º 8
0
    def test_retraction(self):
        # Test that the result is on the manifold and that for small
        # tangent vectors it has little effect.
        x = self.manifold.random_point()
        u = self.manifold.random_tangent_vector(x)

        xretru = self.manifold.retraction(x, u)

        np_testing.assert_allclose(
            multitransp(xretru) @ xretru,
            multieye(self.k, self.n),
            atol=1e-10,
        )

        u = u * 1e-6
        xretru = self.manifold.retraction(x, u)
        np_testing.assert_allclose(xretru, x + u)
Ejemplo n.º 9
0
    def test_random_point(self):
        point = self.so.random_point()
        assert point.shape == (self.n, self.n)
        np_testing.assert_almost_equal(point.T @ point - point @ point.T, 0)
        np_testing.assert_almost_equal(point.T @ point, np.eye(self.n))
        assert np.allclose(np.linalg.det(point), 1)

        point = self.so_product.random_point()
        assert point.shape == (self.k, self.n, self.n)
        np_testing.assert_almost_equal(
            multitransp(point) @ point - point @ multitransp(point),
            0,
        )
        np_testing.assert_almost_equal(
            multitransp(point) @ point, multieye(self.k, self.n)
        )
        assert np.allclose(np.linalg.det(point), 1)
Ejemplo n.º 10
0
    def test_exp(self):
        # Check that exp lies on the manifold and that exp of a small vector u
        # is close to x + u.
        s = self.manifold
        x = s.random_point()
        u = s.random_tangent_vector(x)

        xexpu = s.exp(x, u)
        np_testing.assert_allclose(
            multitransp(xexpu) @ xexpu,
            multieye(self.k, self.n),
            atol=1e-10,
        )

        u = u * 1e-6
        xexpu = s.exp(x, u)
        np_testing.assert_allclose(xexpu, x + u)
Ejemplo n.º 11
0
    def exp(self, point, tangent_vector):
        pt_tv = multitransp(point) @ tangent_vector
        if self._k == 1:
            identity = np.eye(self._p)
        else:
            identity = multieye(self._k, self._p)

        a = np.block([point, tangent_vector])
        b = multiexpm(
            np.block([
                [
                    pt_tv,
                    -multitransp(tangent_vector) @ tangent_vector,
                ],
                [identity, pt_tv],
            ]))[..., :self._p]
        c = multiexpm(-pt_tv)
        return a @ (b @ c)
Ejemplo n.º 12
0
    def test_multieye(self):
        A = np.zeros((self.k, self.n, self.n))
        for i in range(self.k):
            A[i] = np.eye(self.n)

        np_testing.assert_allclose(A, multieye(self.k, self.n))
Ejemplo n.º 13
0
    def test_multieye(self):
        A = np.zeros((self.k, self.n, self.n))
        for i in range(self.k):
            A[i] = np.eye(self.n)

        np_testing.assert_allclose(A, multieye(self.k, self.n))