示例#1
0
 def test_horizontal_lift_and_tangent_submersion(self):
     mat = self.bundle.total_space.random_uniform()
     tangent_vec = GeneralLinear.to_symmetric(
         self.bundle.total_space.random_uniform())
     horizontal = self.bundle.horizontal_lift(tangent_vec, mat)
     result = self.bundle.tangent_submersion(horizontal, mat)
     self.assertAllClose(result, tangent_vec)
示例#2
0
 def test_is_horizontal(self):
     mat = self.bundle.total_space.random_uniform()
     tangent_vec = GeneralLinear.to_symmetric(
         self.bundle.total_space.random_uniform())
     horizontal = self.bundle.horizontal_lift(tangent_vec, mat)
     result = self.bundle.is_horizontal(horizontal, mat)
     self.assertTrue(result)
示例#3
0
    def test_exp(self):
        mat = self.bundle.total_space.random_uniform()
        point = self.bundle.submersion(mat)
        tangent_vec = GeneralLinear.to_symmetric(
            self.bundle.total_space.random_uniform()) / 5

        result = self.quotient_metric.exp(tangent_vec, point)
        expected = self.base_metric.exp(tangent_vec, point)
        self.assertAllClose(result, expected)
    def test_integrability_tensor(self):
        mat = self.bundle.total_space.random_point()
        point = self.bundle.submersion(mat)
        tangent_vec = GeneralLinear.to_symmetric(
            self.bundle.total_space.random_point()) / 5

        self.assertRaises(
            NotImplementedError, lambda: self.bundle.integrability_tensor(
                tangent_vec, tangent_vec, point))
示例#5
0
 def test_inner_product(self):
     mat = self.bundle.total_space.random_point()
     point = self.bundle.submersion(mat)
     tangent_vecs = GeneralLinear.to_symmetric(
         self.bundle.total_space.random_point(2)) / 10
     result = self.quotient_metric.inner_product(
         tangent_vecs[0], tangent_vecs[1], point=mat)
     expected = self.base_metric.inner_product(
         tangent_vecs[0], tangent_vecs[1], point)
     self.assertAllClose(result, expected)
示例#6
0
    def _aux_log(point, sqrt_base_point, inv_sqrt_base_point):
        """Compute the log (auxiliary function).

        Parameters
        ----------
        point : array-like, shape=[..., n, n]
        sqrt_base_point : array-like, shape=[..., n, n]
        inv_sqrt_base_point : array-like, shape=[.., n, n]

        Returns
        -------
        log : array-like, shape=[..., n, n]
        """
        point_near_id = Matrices.mul(
            inv_sqrt_base_point, point, inv_sqrt_base_point)
        point_near_id = GeneralLinear.to_symmetric(point_near_id)

        log_at_id = SPDMatrices.logm(point_near_id)
        log = Matrices.mul(sqrt_base_point, log_at_id, sqrt_base_point)
        return log
示例#7
0
    def _aux_exp(tangent_vec, sqrt_base_point, inv_sqrt_base_point):
        """Compute the exponential map (auxiliary function).

        Parameters
        ----------
        tangent_vec : array-like, shape=[..., n, n]
        sqrt_base_point : array-like, shape=[..., n, n]
        inv_sqrt_base_point : array-like, shape=[..., n, n]

        Returns
        -------
        exp : array-like, shape=[..., n, n]
        """
        tangent_vec_at_id = Matrices.mul(inv_sqrt_base_point, tangent_vec,
                                         inv_sqrt_base_point)

        tangent_vec_at_id = GeneralLinear.to_symmetric(tangent_vec_at_id)
        exp_from_id = SymmetricMatrices.expm(tangent_vec_at_id)

        exp = Matrices.mul(sqrt_base_point, exp_from_id, sqrt_base_point)
        return exp
示例#8
0
    def _aux_log(point, sqrt_base_point, inv_sqrt_base_point):
        """Compute the log (auxiliary function).

        Parameters
        ----------
        point
        sqrt_base_point
        inv_sqrt_base_point

        Returns
        -------
        log
        """
        point_near_id = gs.einsum('...ij,...jk->...ik', inv_sqrt_base_point,
                                  point)
        point_near_id = gs.einsum('...ij,...jk->...ik', point_near_id,
                                  inv_sqrt_base_point)
        point_near_id = GeneralLinear.to_symmetric(point_near_id)
        log_at_id = SPDMatrices.logm(point_near_id)

        log = gs.einsum('...ij,...jk->...ik', sqrt_base_point, log_at_id)
        log = gs.einsum('...ij,...jk->...ik', log, sqrt_base_point)
        return log
示例#9
0
    def _aux_exp(tangent_vec, sqrt_base_point, inv_sqrt_base_point):
        """Compute the exponential map (auxiliary function).

        Parameters
        ----------
        tangent_vec : array-like, shape=[..., n, n]
        sqrt_base_point
        inv_sqrt_base_point

        Returns
        -------
        exp
        """
        tangent_vec_at_id = gs.einsum('...ij,...jk->...ik',
                                      inv_sqrt_base_point, tangent_vec)
        tangent_vec_at_id = gs.einsum('...ij,...jk->...ik', tangent_vec_at_id,
                                      inv_sqrt_base_point)
        tangent_vec_at_id = GeneralLinear.to_symmetric(tangent_vec_at_id)
        exp_from_id = SymmetricMatrices.expm(tangent_vec_at_id)

        exp = gs.einsum('...ij,...jk->...ik', exp_from_id, sqrt_base_point)
        exp = gs.einsum('...ij,...jk->...ik', sqrt_base_point, exp)
        return exp
示例#10
0
 def tangent_submersion(tangent_vec, base_point):
     product = GeneralLinear.mul(base_point,
                                 GeneralLinear.transpose(tangent_vec))
     return 2 * GeneralLinear.to_symmetric(product)