Operator
- class pulser.backend.Operator
Bases:
ABC
,Generic
[ArgScalarType
,ReturnScalarType
,StateType
]Base class enforcing an API for quantum operator.
Each backend will implement its own type of state and the methods below.
Methods
Apply the operator to a state.
Compute the expectation value of self on the given state.
Create an operator from the operator representation.
Signatures
- abstract apply_to(state, /)
Apply the operator to a state.
- abstract expect(state, /)
Compute the expectation value of self on the given state.
- Parameters:
state (
TypeVar
(StateType
, bound=State
)) – The state with which to compute.- Return type:
TypeVar
(ReturnScalarType
)- Returns:
The expectation value.
- classmethod from_operator_repr(*, eigenstates, n_qudits, operations)
Create an operator from the operator representation.
Only operators constructed with this method are allowed in remote backend.
The full operator representation (
FullOp
) is a weigthed sum of tensor operators (TensorOp
), written as a sequence of coefficient and tensor operator pairs, ieFullOp = Sequence[tuple[ScalarType, TensorOp]]
Each
TensorOp
is itself a sequence of qudit operators (QuditOp
) applied to mutually exclusive sets of qudits (represented by their indices), ieTensorOp = Sequence[tuple[QuditOp, Collection[int]]]
Qudits without an associated
QuditOp
are applied the identity operator.Finally, each
QuditOp
is represented as weighted sum of pre-defined single-qudit operators. It is given as a mapping between a string representation of the single-qudit operator and its respective coefficient, ieQuditOp = Mapping[str, ScalarType]
By default it identifies strings
"ij"
as single-qudit operators, wherei
andj
are eigenstates that denote|i><j|
.- Parameters:
eigenstates (
Sequence
[Literal
['u'
,'d'
,'r'
,'g'
,'h'
,'x'
] |Literal
['0'
,'1'
]]) – The eigenstates to use.n_qubits – How many qubits there are in the system.
operations (
Sequence
[tuple
[TypeVar
(ArgScalarType
),Sequence
[tuple
[Mapping
[str
,TypeVar
(ArgScalarType
)],Collection
[int
]]]]]) – The full operator representation.
- Return type:
TypeVar
(OperatorType
, bound= Operator)- Returns:
The constructed operator.