def test_simple_trace_cases_symbolic_dim():
from sympy import symbols
D = symbols('D')
G = GammaMatrixHead(dim=D)
m0, m1, m2, m3 = tensor_indices('m0:4', G.LorentzIndex)
g = G.LorentzIndex.metric
t = G(m0)*G(m1)
t1 = G._trace_single_line(t)
assert _is_tensor_eq(t1, 4 * G.LorentzIndex.metric(m0, m1))
t = G(m0)*G(m1)*G(m2)*G(m3)
t1 = G._trace_single_line(t)
t2 = -4*g(m0, m2)*g(m1, m3) + 4*g(m0, m1)*g(m2, m3) + 4*g(m0, m3)*g(m1, m2)
assert _is_tensor_eq(t1, t2)
评论列表
文章目录