def test_tensor_product_abstract(): assert TP(x * A, 2 * B) == x * 2 * TP(A, B) assert TP(A, B) != TP(B, A) assert TP(A, B).is_commutative == False assert isinstance(TP(A, B), TP) assert TP(A, B).subs(A, C) == TP(C, B)
def test_tensor_product_simp(): assert tensor_product_simp(TP(A, B) * TP(B, C)) == TP(A * B, B * C) # tests for Pow-expressions assert tensor_product_simp(TP(A, B)**x) == TP(A**x, B**x) assert tensor_product_simp(x * TP(A, B)**2) == x * TP(A**2, B**2) assert tensor_product_simp(x * (TP(A, B)**2) * TP(C, D)) == x * TP(A**2 * C, B**2 * D) assert tensor_product_simp(TP(A, B) - TP(C, D)**x) == TP(A, B) - TP(C**x, D**x)
def test_tensor_product_commutator(): assert TP(Comm(A, B), C).doit().expand(tensorproduct=True) == \ TP(A*B, C) - TP(B*A, C) assert Comm(TP(A, B), TP(B, C)).doit() == \ TP(A, B)*TP(B, C) - TP(B, C)*TP(A, B)
def test_tensor_product_expand(): assert TP(A + B, B + C).expand(tensorproduct=True) == \ TP(A, B) + TP(A, C) + TP(B, B) + TP(B, C)
def test_tensor_product_simp(): assert tensor_product_simp(TP(A, B) * TP(B, C)) == TP(A * B, B * C)