コード例 #1
0
 def to_matrix(self):
     """Test to_matrix method."""
     labels = ['XI', 'YZ', 'YY', 'ZZ']
     coeffs = [-3, 4.4j, 0.2 - 0.1j, 66.12]
     spp_op = SparsePauliOp(PauliTable.from_labels(labels), coeffs)
     target = np.zeros((4, 4), dtype=complex)
     for coeff, label in zip(coeffs, labels):
         target += coeff * pauli_mat(label)
     self.assertTrue(np.array_equal(spp_op.to_matrix(), target))
コード例 #2
0
 def to_matrix(self):
     """Test to_matrix method."""
     labels = ["XI", "YZ", "YY", "ZZ"]
     coeffs = [-3, 4.4j, 0.2 - 0.1j, 66.12]
     spp_op = SparsePauliOp(labels, coeffs)
     target = np.zeros((4, 4), dtype=complex)
     for coeff, label in zip(coeffs, labels):
         target += coeff * pauli_mat(label)
     np.testing.assert_array_equal(spp_op.to_matrix(), target)