def test_log_and_exp_power_affine(self): base_point = gs.array([[5., 0., 0.], [0., 7., 2.], [0., 2., 8.]]) point = gs.array([[9., 0., 0.], [0., 5., 0.], [0., 0., 1.]]) metric = SPDMetricAffine(3, power_affine=.5) log = metric.log(point, base_point) result = metric.exp(log, base_point) expected = point self.assertAllClose(result, expected)
def test_estimate_spd_two_samples(self): space = SPDMatrices(3) metric = SPDMetricAffine(3) point = space.random_point(2) mean = FrechetMean(metric) mean.fit(point) result = mean.estimate_ expected = metric.exp(metric.log(point[0], point[1]) / 2, point[1]) self.assertAllClose(expected, result)
def test_log_and_exp_power_affine(self): """Test of SPDMetricAffine.log and exp methods with power!=1.""" base_point = gs.array([[5.0, 0.0, 0.0], [0.0, 7.0, 2.0], [0.0, 2.0, 8.0]]) point = gs.array([[9.0, 0.0, 0.0], [0.0, 5.0, 0.0], [0.0, 0.0, 1.0]]) metric = SPDMetricAffine(3, power_affine=0.5) log = metric.log(point, base_point) result = metric.exp(log, base_point) expected = point self.assertAllClose(result, expected)
def test_log(self, n, power_affine, point, base_point, expected): metric = SPDMetricAffine(n, power_affine) self.assertAllClose( metric.log(gs.array(point), gs.array(base_point)), gs.array(expected) )