mirror of https://github.com/Qiskit/qiskit.git
46 lines
1.7 KiB
YAML
46 lines
1.7 KiB
YAML
---
|
|
features:
|
|
- |
|
|
The :class:`~qiskit.opflow.primitive_ops.Z2Symmetries` class now exposes
|
|
the threshold tolerances used to chop small real and imaginary parts of
|
|
coefficients. With this one can control how the coefficients of the tapered
|
|
operator are simplified. For example::
|
|
|
|
from qiskit.opflow import Z2Symmetries
|
|
from qiskit.quantum_info import Pauli
|
|
|
|
z2_symmetries = Z2Symmetries(
|
|
symmetries=[Pauli("IIZI"), Pauli("IZIZ"), Pauli("ZIII")],
|
|
sq_paulis=[Pauli("IIXI"), Pauli("IIIX"), Pauli("XIII")],
|
|
sq_list=[1, 0, 3],
|
|
tapering_values=[1, -1, -1],
|
|
tol=1e-10,
|
|
)
|
|
|
|
By default, coefficients are chopped with a tolerance of ``tol=1e-14``.
|
|
- |
|
|
Added a :meth:`~qiskit.quantum_info.SparsePauliOp.chop` method to the
|
|
:class:`~qiskit.quantum_info.SparsePauliOp` class that truncates real and
|
|
imaginary parts of coefficients individually. This is different
|
|
from the :meth:`.SparsePauliOp.simplify` method which
|
|
removes a coefficient only if the absolute value is close to 0. For
|
|
example::
|
|
|
|
>>> from qiskit.quantum_info import SparsePauliOp
|
|
>>> op = SparsePauliOp(["X", "Y", "Z"], coeffs=[1+1e-17j, 1e-17+1j, 1e-17])
|
|
>>> op.simplify()
|
|
SparsePauliOp(['X', 'Y'],
|
|
coeffs=[1.e+00+1.e-17j, 1.e-17+1.e+00j])
|
|
>>> op.chop()
|
|
SparsePauliOp(['X', 'Y'],
|
|
coeffs=[1.+0.j, 0.+1.j])
|
|
|
|
Note that the chop method does not accumulate the coefficients of the same Paulis, e.g.
|
|
|
|
.. code-block::
|
|
|
|
>>> op = SparsePauliOp(["X", "X"], coeffs=[1+1e-17j, 1e-17+1j)
|
|
>>> op.chop()
|
|
SparsePauliOp(['X', 'X'],
|
|
coeffs=[1.+0.j, 0.+1.j])
|