4f66fc666b02553d74521a732948f80fe6cfe0c2,geomstats/special_orthogonal_group.py,SpecialOrthogonalGroup,jacobian_translation,#SpecialOrthogonalGroup#Any#Any#,520

Before Change


        :param rot_vec: 3D rotation vector
        :returns jacobian: 3x3 matrix
        
        if self.n != 3:
            raise NotImplementedError(
                "jacobian_translation not implemented for n != 3.")

        assert self.belongs(point)
        assert left_or_right in ("left", "right")
        point = self.regularize(point)
        n_points, _ = point.shape

After Change


        assert self.belongs(point)
        assert left_or_right in ("left", "right")

        if self.n == 3:
            point = self.regularize(point)
            n_points, _ = point.shape

            angle = np.linalg.norm(point, axis=1)
            angle = np.expand_dims(angle, axis=1)

            coef_1 = np.zeros([n_points, 1])
            coef_2 = np.zeros([n_points, 1])

            mask_0 = np.isclose(angle, 0)
            mask_0 = np.squeeze(mask_0, axis=1)
            coef_1[mask_0] = (1 - angle[mask_0] ** 2 / 12
                              - angle[mask_0] ** 4 / 720
                              - angle[mask_0] ** 6 / 30240)
            coef_2[mask_0] = (1 / 12 + angle[mask_0] ** 2 / 720
                              + angle[mask_0] ** 4 / 30240
                              + angle[mask_0] ** 6 / 1209600)

            mask_pi = np.isclose(angle, np.pi)
            mask_pi = np.squeeze(mask_pi, axis=1)
            delta_angle = angle[mask_pi] - np.pi
            coef_1[mask_pi] = (- np.pi * delta_angle / 4
                               - delta_angle ** 2 / 4
                               - np.pi * delta_angle ** 3 / 48
                               - delta_angle ** 4 / 48
                               - np.pi * delta_angle ** 5 / 480
                               - delta_angle ** 6 / 480)
            coef_2[mask_pi] = (1 - coef_1[mask_pi]) / angle[mask_pi] ** 2

            mask_else = ~mask_0 & ~mask_pi
            coef_1[mask_else] = ((angle[mask_else] / 2)
                                 / np.tan(angle[mask_else] / 2))
            coef_2[mask_else] = (1 - coef_1[mask_else]) / angle[mask_else] ** 2

            jacobian = np.zeros((n_points, self.dimension, self.dimension))

            for i in range(n_points):
                if left_or_right == "left":
                    jacobian[i] = (coef_1[i] * np.identity(self.dimension)
                                   + coef_2[i] * np.outer(point[i], point[i])
                                   + skew_matrix_from_vector(point[i]) / 2)

                else:
                    jacobian[i] = (coef_1[i] * np.identity(self.dimension)
                                   + coef_2[i] * np.outer(point[i], point[i])
                                   - skew_matrix_from_vector(point[i]) / 2)

        else:
            if left_or_right == "right":
                raise NotImplementedError(
                    "The jacobian of the right translation"
                    " is not implemented.")
            jacobian = self.matrix_from_rotation_vector(point)

        assert jacobian.ndim == 3
        return jacobian

    def random_uniform(self, n_samples=1):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: geomstats/geomstats
Commit Name: 4f66fc666b02553d74521a732948f80fe6cfe0c2
Time: 2018-04-25
Author: ninamio78@gmail.com
File Name: geomstats/special_orthogonal_group.py
Class Name: SpecialOrthogonalGroup
Method Name: jacobian_translation


Project Name: geomstats/geomstats
Commit Name: bfc0419ebc68ef4b9b53c8aad509d76a0a61bcea
Time: 2018-04-27
Author: ninamio78@gmail.com
File Name: geomstats/special_orthogonal_group.py
Class Name: SpecialOrthogonalGroup
Method Name: jacobian_translation


Project Name: geomstats/geomstats
Commit Name: 6f24156319db9e6a65af826b0aa817647ccef577
Time: 2018-07-24
Author: ninamio78@gmail.com
File Name: geomstats/special_orthogonal_group.py
Class Name: SpecialOrthogonalGroup
Method Name: group_exponential_barycenter