quairkit.core.state.backend.operator¶
Source file for base class that emulates quantum states.
- class quairkit.core.state.backend.operator.StateOperator(list_operator, sys_dim)¶
The abstract base class for operating quantum state in QuAIRKit, via emulators or quantum devices.
- Parameters:¶
- list_operator : List[OperatorInfoType] | None¶
the operators of the circuit that applies to the state. Defaults to an empty list.
- sys_dim : List[int]¶
a list of dimensions for each system.
Note
This class is designed to be inherited by specific state emulator classes. Such class should emulate quantum computing via OpenQASM 2.0.
- property param : list[Tensor]¶
The parameters stored in the operators in StateOperator.
- apply(list_operator)¶
Record a list of operators that will be applied to the device.
- Parameters:¶
- list_operator : List[OperatorInfoType | List[OperatorInfoType]]¶
the list of operators that applies to the state.
- property qasm2 : str¶
The QASM 2.0 string that represents the circuit stored in this state emulator.
- property system_dim : list[int]¶
The list of dimensions for each system
- abstract clone()¶
Return a copy of the quantum state.
-
measure(system_idx=
None
, shots=None
, measure_op=None
)¶ Measure the quantum state
- Parameters:¶
- system_idx : int | List[int] | None¶
the system indices to be measured. Defaults to all systems.
- shots : int | None¶
the number of shots to measure, defaults to 1024.
- measure_op : str | None¶
the measurement operator basis to measure. Here we restrict it to be Pauli, which can be a char or a string composed of ‘i’, ‘x’, ‘y’, or ‘z’. Defaults to ‘z’.
- Returns:¶
A tensor containing the measurement results, where each element corresponds to empirical probabilities of the measurement outcomes.
- Return type:¶
Tensor
-
expec_val(hamiltonian, shots=
None
, decompose=False
)¶ The expectation value of the observable with respect to the quantum state.
- Parameters:¶
- hamiltonian : Hamiltonian¶
Input observable.
- shots : int | None¶
the total number of shots to measure, defaults to 1024 times the Hamiltonian terms.
- decompose : bool¶
If decompose is
True
, it will return the expectation value of each term.
- Returns:¶
The measured expectation value (per term) of the input observable for the quantum state.
- Return type:¶
Tensor