mindquantum.core.operators.QubitExcitationOperator

View Source On Gitee
class mindquantum.core.operators.QubitExcitationOperator(term=None, coefficient=1.0)[source]

QubitExcitationOperator class.

The Qubit Excitation Operator is defined as: \(Q^{\dagger}_{n} = \frac{1}{2} (X_{n} - iY_{n})\) and \(Q_{n} = \frac{1}{2} (X_{n} + iY_{n})\). Compared with Fermion excitation operators, Qubit excitation operators are some kind of "localized", i.e., the Fermion excitation operator \(a^{\dagger}_{7} a_{0}\) involves qubit ranging from 0 to 7 under JW transformation, while Qubit excitation \(Q^{\dagger}_{7} Q_{0}\) will only affect the 0th and 7th qubits. In addition, double excitations described using Qubit excitation operators use much less CNOTs than the corresponding Fermion excitation operators.

Parameters
  • terms (Union[str, tuple]) – The input term of qubit excitation operator. Default: None.

  • coefficient (Union[numbers.Number, str, ParameterResolver]) – The coefficient for the corresponding single operators Default: 1.0.

Examples

>>> from mindquantum.algorithm.nisq import Transform
>>> from mindquantum.core.operators import QubitExcitationOperator
>>> op = QubitExcitationOperator(((4, 1), (1, 0), (0, 0)), 2.5)
>>> op
5/2 [Q4^ Q1 Q0]
>>> op.fermion_operator
5/2 [4^ 1 0]
>>> op.to_qubit_operator()
5/16 [X0 X1 X4] +
(-0.3125j) [X0 X1 Y4] +
(5/16j) [X0 Y1 X4] +
5/16 [X0 Y1 Y4] +
(5/16j) [Y0 X1 X4] +
5/16 [Y0 X1 Y4] +
-0.3125 [Y0 Y1 X4] +
(5/16j) [Y0 Y1 Y4]
>>> Transform(op.fermion_operator).jordan_wigner()
5/16 [X0 X1 Z2 Z3 X4] +
(-0.3125j) [X0 X1 Z2 Z3 Y4] +
(5/16j) [X0 Y1 Z2 Z3 X4] +
5/16 [X0 Y1 Z2 Z3 Y4] +
(5/16j) [Y0 X1 Z2 Z3 X4] +
5/16 [Y0 X1 Z2 Z3 Y4] +
-0.3125 [Y0 Y1 Z2 Z3 X4] +
(5/16j) [Y0 Y1 Z2 Z3 Y4]
hermitian()[source]

Return Hermitian conjugate of QubitExcitationOperator.

property imag

Convert the coefficient to its imag part.

Returns

QubitExcitationOperator, the image part of this qubit excitation operator.

Examples

>>> from mindquantum.core.operators import QubitExcitationOperator
>>> f = QubitExcitationOperator(((1, 0),), 1 + 2j)
>>> f += QubitExcitationOperator(((1, 1),), 'a')
>>> f.imag.compress()
2 [Q1]
normal_ordered()[source]

Return the normal ordered form of the Qubit excitation operator.

Note

Unlike Fermion excitation operators, Qubit excitation operators will not multiply -1 when the order is swapped.

Returns

QubitExcitationOperator, the normal ordered operator.

Examples

>>> from mindquantum.core.operators import QubitExcitationOperator
>>> op = QubitExcitationOperator("7 1^")
>>> op
1 [Q7 Q1^]
>>> op.normal_ordered()
1 [Q1^ Q7]
property real

Convert the coefficient to its real part.

Returns

QubitExcitationOperator, the real part of this qubit excitation operator.

Examples

>>> from mindquantum.core.operators import QubitExcitationOperator
>>> f = QubitExcitationOperator(((1, 0),), 1 + 2j)
>>> f += QubitExcitationOperator(((1, 1),), 'a')
>>> f.real.compress()
1 [Q1] +
a [Q1^]
to_qubit_operator()[source]

Convert the Qubit excitation operator to the equivalent Qubit operator.

Returns

QubitOperator, The corresponding QubitOperator according to the definition of Qubit excitation operators.

Examples

>>> from mindquantum.core.operators import QubitExcitationOperator
>>> op = QubitExcitationOperator("7^ 1")
>>> op.to_qubit_operator()
1/4 [X1 X7] +
(-1/4j) [X1 Y7] +
(1/4j) [Y1 X7] +
1/4 [Y1 Y7]