예제 #1
0
def test_wrap_around():
    a = np.array([+1, 0])
    b = np.array([-1, 0])

    bv = S1.logmap(a, b)
    b2 = S1.expmap(bv)
    d = S1.distance(b, b2)

    printm('a', a, 'b', b, 'vel', bv[1], 'd', np.array(d))
    check_allclose(d, 0, atol=1e-7)
예제 #2
0
    def embedding(A, B, A_to_B, B_to_A, itype='user', steps=None, desc=None):
        if A.dimension > B.dimension:
            msg = ('You are trying to define an embedding'
                    ' from a large to a smaller manifold:\n'
                    '- %s has dimension %d;\n'
                    '- %s has dimension %d.\n' % (A, A.dimension,
                                                  B, B.dimension))
            raise ValueError(msg)

        if steps is None:
            steps = [(A, '=', B)]
        ManifoldRelations.set_embedding(A, B, Embedding(A, B, A_to_B, B_to_A, steps, itype, desc))
        ManifoldRelations.set_projection(B, A, Embedding(B, A, B_to_A, A_to_B, steps, itype, desc))

        # TODO: move somewhere
        if False:
        # if development:
            try:
                for a in A.interesting_points():
                    A.belongs(a)
                    b = A_to_B(a)
                    B.belongs(b)
            except:
                print('Invalid embedding:\n %s -> %s using %s' % (A, B,
                                                                  A_to_B))
                printm('a', a)
                raise

            try:
                for b in B.interesting_points():
                    B.belongs(b)
                    a = B_to_A(b)
                    A.belongs(a)
            except:
                printm('b', b)
                print('Invalid embedding:\n %s <- %s using %s' % 
                      (A, B, B_to_A))
                raise