Package geometry :: Package manifolds :: Module euclidean
[hide private]
[frames] | no frames]

Source Code for Module geometry.manifolds.euclidean

 1  from . import (np, assert_allclose, contract, MatrixLinearSpace) 
2 3 4 -class Euclidean(MatrixLinearSpace):
5 ''' 6 This is the usual Euclidean space of finite dimension; 7 this is mostly used for debugging. 8 9 There is no proper Haar measure; as an arbitrary choice, 10 the :py:func:`sample_uniform` 11 returns a sample from a Gaussian distribution centered at 0. 12 13 ''' 14
15 - def __init__(self, dimension):
16 MatrixLinearSpace.__init__(self, dimension=dimension, 17 shape=(dimension,))
18
19 - def __repr__(self):
20 return 'R%s' % (self.dimension)
21 22 @contract(x='array')
23 - def belongs(self, x):
24 assert_allclose(x.size, self.dimension) 25 assert np.all(np.isreal(x)), "Expected real vector"
26
27 - def sample_uniform(self):
28 return np.random.randn(self.dimension)
29
30 - def interesting_points(self):
31 points = [] 32 points.append(np.zeros(self.dimension)) 33 points.append(np.ones(self.dimension)) 34 return points
35
36 - def project(self, x):
37 return x
38