Source code for qiskit_dynamics.systems.subsystem_operators
# This code is part of Qiskit.## (C) Copyright IBM 2025.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals.# pylint: disable=invalid-name"""Concrete subsystem operators."""importnumpyasnpfrom.abstract_subsystem_operatorsimportAbstractSubsystemOperator
[docs]classSubsystemOperator(AbstractSubsystemOperator):"""A concrete operator specified in terms of a matrix."""def__init__(self,matrix,subsystems,str_label=None):"""Initialize. Args: matrix: The matrix of the operator. subsystems: The ordered subsystems representing the tensor factor system the matrix is specified on. """ifmatrix.shape[0]!=np.prod([s.dimforsinsubsystems]):raiseValueError("Subsystem dimensions don't match matrix shape.")self._matrix=matrixself._str_label=str_labelsuper().__init__(subsystems)
[docs]classA(AbstractSubsystemOperator):r"""Annihilation operator. Defined as the matrix with non-zero entries :math:`0, 1, \sqrt{2}, ..., \sqrt{n - 1}` in the first off-diagonal, where :math:`n` is the dimension of the subsystem being acted on. """
[docs]classAdag(AbstractSubsystemOperator):r"""Creation operator. Defined as the matrix with non-zero entries :math:`0, 1, \sqrt{2}, ..., \sqrt{n - 1}` in the first lower off-diagonal, where :math:`n` is the dimension of the subsystem being acted on. """
[docs]classN(AbstractSubsystemOperator):"""The number operator. Defined as the diagonal matrix with with entries ``[0, ..., dim - 1]``, where ``dim`` is the dimension of the :class:`Subsystem` the operator is defined on. """
[docs]classY(AbstractSubsystemOperator):"""Y operator. The standard Pauli :math:`Y` operator, generalized to ``-1j * (A - Adag)`` for higher dimensions. """