Esempio n. 1
0
    def dist(self,
             z1: torch.Tensor,
             z2: torch.Tensor,
             *,
             keepdim=False) -> torch.Tensor:
        """
        To compute the distance in the Bounded Domain Model (BDM) we need to map the elements to the
        Upper Half Space Model (UHSM) by means of the inverse Cayley Transform, and then compute the distance
        in that domain.

        :param z1, z2: b x 2 x n x n: elements in the BDM
        :param keepdim:
        :return: distance between x and y
        """
        uhsm_z1 = inverse_cayley_transform(z1)
        uhsm_z2 = inverse_cayley_transform(z2)
        return super().dist(uhsm_z1, uhsm_z2)
Esempio n. 2
0
    def test_inverse_cayley_transform(self):
        x = self.bounded_manifold.random(10)

        tran_x = inverse_cayley_transform(x)
        result = cayley_transform(tran_x)

        self.assertAllClose(x, result)
        # the intermediate result belongs to the Upper Half Space manifold
        for point in tran_x:
            self.assertTrue(self.upper_half_manifold.check_point_on_manifold(point))
        # the final result belongs to the Bounded domain manifold
        for point in result:
            self.assertTrue(self.bounded_manifold.check_point_on_manifold(point))
Esempio n. 3
0
    def test_cayley_transform_from_projx(self):
        x = get_random_symmetric_matrices(10, 3)
        x = self.upper_half_manifold.projx(x)

        tran_x = cayley_transform(x)
        result = inverse_cayley_transform(tran_x)

        self.assertAllClose(x, result)
        # the intermediate result belongs to the Bounded domain manifold
        for point in tran_x:
            self.assertTrue(self.bounded_manifold.check_point_on_manifold(point))
        # the final result belongs to the Upper Half Space manifold
        for point in result:
            self.assertTrue(self.upper_half_manifold.check_point_on_manifold(point))
Esempio n. 4
0
    def test_cayley_transform_real_neg_imag_pos(self):
        x = self.upper_half_manifold.random(10)
        x = sm.stick(sm.real(x) * -1, sm.imag(x))

        tran_x = cayley_transform(x)
        result = inverse_cayley_transform(tran_x)

        self.assertAllClose(x, result)
        # the intermediate result belongs to the Bounded domain manifold
        for point in tran_x:
            self.assertTrue(self.bounded_manifold.check_point_on_manifold(point))
        # the final result belongs to the Upper Half Space manifold
        for point in result:
            self.assertTrue(self.upper_half_manifold.check_point_on_manifold(point))