def test_KroneckerProduct_is_associative(): assert kronecker_product(A, kronecker_product( B, C)) == kronecker_product(kronecker_product(A, B), C) assert kronecker_product(A, kronecker_product( B, C)) == KroneckerProduct(A, B, C)
def test_KroneckerProduct_isnt_commutative(): assert KroneckerProduct(A, B) != KroneckerProduct(B, A) assert KroneckerProduct(A, B).is_commutative == False
def test_tensor_product_conjugate(): assert KroneckerProduct(I*A, B).conjugate() == \ -I*KroneckerProduct(A.conjugate(), B.conjugate()) assert KroneckerProduct(mat1, mat2).conjugate() == \ kronecker_product(mat1.conjugate(), mat2.conjugate())
def test_tensor_product_transpose(): assert KroneckerProduct(I*A, B).transpose() == \ I*KroneckerProduct(A.transpose(), B.transpose()) assert KroneckerProduct(mat1, mat2).transpose() == \ kronecker_product(mat1.transpose(), mat2.transpose())
def test_tensor_product_adjoint(): assert KroneckerProduct(I*A, B).adjoint() == \ -I*KroneckerProduct(A.adjoint(), B.adjoint()) assert KroneckerProduct(mat1, mat2).adjoint() == \ kronecker_product(mat1.adjoint(), mat2.adjoint())
def test_KroneckerProduct_identity(): assert KroneckerProduct(Identity(m), Identity(n)) == Identity(m*n) assert KroneckerProduct(eye(2), eye(3)) == eye(6)
def test_KroneckerProduct(): assert isinstance(KroneckerProduct(A, B), KroneckerProduct) assert KroneckerProduct(A, B).subs(A, C) == KroneckerProduct(C, B) assert KroneckerProduct(A, C).shape == (n*m, m*k) assert (KroneckerProduct(A, C) + KroneckerProduct(-A, C)).is_ZeroMatrix assert (KroneckerProduct(W, Z) * KroneckerProduct(W.I, Z.I)).is_Identity
def test_KroneckerProduct_entry(): A = MatrixSymbol('A', n, m) B = MatrixSymbol('B', o, p) assert KroneckerProduct(A, B)._entry(i, j) == A[Mod(floor(i/o), n), Mod(floor(j/p), m)]*B[Mod(i, o), Mod(j, p)]
def test_KroneckerProduct_extracts_commutative_part(): assert kronecker_product(x * A, 2 * B) == x * \ 2 * KroneckerProduct(A, B)