|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Trotterization Algorithm Base"""
|
|
|
|
from abc import abstractmethod
|
|
|
|
from qiskit.opflow.evolutions.evolution_base import EvolutionBase
|
|
from qiskit.opflow.operator_base import OperatorBase
|
|
from qiskit.utils.deprecation import deprecate_func
|
|
|
|
|
|
|
|
|
|
class TrotterizationBase(EvolutionBase):
|
|
"""Deprecated: A base for Trotterization methods, algorithms for approximating exponentiations of
|
|
operator sums by compositions of exponentiations.
|
|
"""
|
|
|
|
@deprecate_func(
|
|
since="0.24.0",
|
|
additional_msg="For code migration guidelines, visit https://qisk.it/opflow_migration.",
|
|
)
|
|
def __init__(self, reps: int = 1) -> None:
|
|
super().__init__()
|
|
self._reps = reps
|
|
|
|
@property
|
|
def reps(self) -> int:
|
|
"""The number of repetitions to use in the Trotterization, improving the approximation
|
|
accuracy.
|
|
"""
|
|
return self._reps
|
|
|
|
@reps.setter
|
|
def reps(self, reps: int) -> None:
|
|
r"""Set the number of repetitions to use in the Trotterization."""
|
|
self._reps = reps
|
|
|
|
@abstractmethod
|
|
def convert(self, operator: OperatorBase) -> OperatorBase:
|
|
r"""
|
|
Convert a ``SummedOp`` into a ``ComposedOp`` or ``CircuitOp`` representing an
|
|
approximation of e^-i*``op_sum``.
|
|
|
|
Args:
|
|
operator: The ``SummedOp`` to evolve.
|
|
|
|
Returns:
|
|
The Operator approximating op_sum's evolution.
|
|
|
|
Raises:
|
|
TypeError: A non-SummedOps Operator is passed into ``convert``.
|
|
|
|
"""
|
|
raise NotImplementedError
|
|
|
|
|
|
|