def test_mul_sparse_broadcast(self, mat_s, ket_d): ca = mul(mat_s, ket_d) cn = np.multiply(mat_s.A, ket_d) assert_allclose(ca.A, cn) ca = mul(mat_s.H, ket_d) cn = np.multiply(mat_s.H.A, ket_d) assert_allclose(ca.A, cn)
def test_mul_broadcast(self, mat_d, ket_d): ca = mul(mat_d, ket_d) assert isinstance(ca, np.matrix) cn = np.multiply(mat_d, ket_d) assert_allclose(ca, cn) ca = mul(mat_d.H, ket_d) assert isinstance(ca, np.matrix) cn = np.multiply(mat_d.H, ket_d) assert_allclose(ca, cn)
def test_mul_sparse(self, mat_s, mat_s2): cq = mul(mat_s, mat_s2) cn = mat_s.A * mat_s2.A assert issparse(cq) assert_allclose(cq.A, cn) cq = mul(mat_s2.A, mat_s) cn = mat_s2.A * mat_s.A assert issparse(cq) assert_allclose(cq.A, cn)
def test_mul_dense_same(self, mat_d, mat_d2): ca = mul(mat_d, mat_d2) assert isinstance(ca, np.matrix) cn = np.multiply(mat_d, mat_d2) assert_allclose(ca, cn)