Exemplo n.º 1
0
def test_remove_ids():
    assert remove_ids(MatMul(A, Identity(m), B, evaluate=False)) == \
                      MatMul(A, B, evaluate=False)
    assert null_safe(remove_ids)(MatMul(Identity(n), evaluate=False)) == \
                                 MatMul(Identity(n), evaluate=False)
Exemplo n.º 2
0
# sympy
#A = MatrixSymbol('A',12,12)	# coefficient matrix : Aのi列目が ei' の係数
A_inputEs = MatrixSymbol('A_inputEs', 3, 2)
A_inputRs = MatrixSymbol('A_inputRs', 2, 1)
q = MatrixSymbol('q', 1, 2)
p_i = MatrixSymbol('p_i', 1, 12)  # updated point
E = MatrixSymbol('E', 12, 12)  # = (e1 e2 e0 P[thisID] 0 ...) : 縦ベクトルの列
var = (q, p_i, E, A_inputEs, A_inputRs)
A = Matrix(np.zeros(144).reshape(12, 12))
A[0:3, 0:2] = Matrix(A_inputEs)
A[0:2, 0:1] = Matrix(A_inputRs)

_E = E * A  # = (e1' e2' R1 0 ...) : 縦ベクトルの列

constraints1 = remove_ids(refine(_E.T * _E, Q.orthogonal(E)))
constraints2 = remove_ids(refine(E.T * _E, Q.orthogonal(E)))
constraints3 = p_i * _E

# ei' * ej' = δij (クロネッカーのデルタ)
bases_e = Matrix(constraints1[0:2, 0:2] - Identity(2))
_bases_e = bases_e[0, 0]**2 + bases_e[0, 1]**2 + bases_e[1, 1]**2

# Ri * Rj = δij (クロネッカーのデルタ)
bases_r = Matrix(constraints1[2:3, 2:3] - Identity(1))
_bases_r = bases_r[0, 0]**2

# _Ei.dot(Rj) - sp.Matrix(Ei).dot(Rj),
eMulR = Matrix(constraints1[0:2, 2:3] - constraints2[0:2, 2:3])
_eMulR = eMulR[0, 0]**2 + eMulR[1, 0]**2
Exemplo n.º 3
0
	for i in range(node_num):
		Xs_scaled[i] = scale(Xs[i], True);Ys_scaled[i] = scale(Ys[i], False)

update_points()

print("init: ready")

# sympy
A = MatrixSymbol('A',high_dim,high_dim)
q = MatrixSymbol('q', 1, dim)  # values
E = sp.MatrixSymbol('E', high_dim, high_dim) # = (E[0], E[1], ..., E[dim-1] P[thisID] 0 ...).T
var = (q,E,A)

_E = E * A  # = (e1' e2' e3' ... R1 R2 ...)

constraints1 = remove_ids(refine(_E.T * _E, Q.orthogonal(E)))
constraints2 = remove_ids(refine(E * _E, Q.orthogonal(E)))

bases_e = Matrix(constraints1[0:dim,0:dim] - Identity(dim))
_bases_e = Matrix.norm(bases_e)

bases_r = Matrix(constraints1[dim:2*dim-1,dim:2*dim-1] - Identity(dim-1))
_bases_r = Matrix.norm(bases_r)

# _Ei.dot(Rj) - sp.Matrix(Ei).dot(Rj),
eMulR =  Matrix(constraints1[0:dim,dim:2*dim-1] - constraints2[0:dim,dim:2*dim-1])
_eMulR = Matrix.norm(eMulR)


# sp.Matrix(P_i).dot(_Ej) - wj
pew = Matrix(constraints2[dim,0:dim] - q)
Exemplo n.º 4
0
def test_remove_ids():
    assert remove_ids(MatMul(A, Identity(m), B, evaluate=False)) == \
                      MatMul(A, B, evaluate=False)
    assert null_safe(remove_ids)(MatMul(Identity(n), evaluate=False)) == \
                                 MatMul(Identity(n), evaluate=False)
Exemplo n.º 5
0
from sympy import *
from functools import *
from sympy.matrices.expressions.matmul import remove_ids

#l = Symbol('l')
l = 5
T = MatrixSymbol('T', l, l)
M = MatrixSymbol('M', l, l) # M = [[e1],[e2],[e3],0]
tM = M * T

facts = Q.orthogonal(M)

t2M2 = remove_ids(refine(tM.T * tM, facts))

print(t2M2)
"""
a = Symbol('a',real=True)
b = Symbol('b',real=True)
e1 = a*M[:,0] + b*M[:,1]

print(simplify(refine(e1.T * e1, Q.orthogonal(M))))
"""

#print(reduce(lambda a, x: a + x, [ a2M2[i, j] for i in range(0, 3) for j in range(0, 3)]))