cuquantum.densitymat.Operator¶
- class cuquantum.densitymat.Operator(hilbert_space_dims, *terms)[source]¶
Operator representing a collection of
OperatorTermobjects.The action of an
Operatormaps aStateto anotherState. AnOperatoracts on an instance ofStatethrough itscomputemethod after itspreparemethod is called on the same instance ofState.- Parameters
hilbert_space_dims – Hilbert space dimensions of the physical system.
terms – A sequence of tuples specifying each term. Each tuple can consist of a single element (
OperatorTerm), two elements (OperatorTermand coefficient), or three elements (OperatorTerm, coefficient and duality). If the second or third element is not given, they will be set to the default values (coefficient=1,duality=False).
Methods
- __add__(other: Operator) Operator[source]¶
Return a new
Operatorequal to the sum of thisOperatorwith anotherOperator.
- __iadd__(other: Union[Operator, OperatorTerm]) None[source]¶
Inplace add another
OperatororOperatorTerminto thisOperator.
- __init__(hilbert_space_dims: Sequence[int], *terms: Tuple[OperatorTerm, Optional[Union[numbers.Number, Tuple]], Optional[bool]]) None[source]¶
Initialize an operator representing a collection of
OperatorTermobjects.
- __mul__(scalar) Operator[source]¶
Return a new
Operatorequal to thisOperatormultiplied by a scalar on the left.
- __rmul__(scalar) Operator[source]¶
Return a new
Operatorequal to thisOperatormultiplied by a scalar on the right.
- __sub__(other: Operator) Operator[source]¶
Return the difference of this
Operatorwith anotherOperator.
- append(term: OperatorTerm, coeff: Union[numbers.Number, Callable[[numbers.Number, Sequence], numbers.Number]] = 1.0, duality: bool = False) None[source]¶
Append an
OperatorTermto thisOperator.- Parameters
term – The
OperatorTermto be appended.coeff – The coefficient associated with this
OperatorTerm.duality – Whether the elementary operators in
termare applied on ket modes (False) or bra modes (True).
- compute_action(t: float, params: list[float], state_in: State, state_out: State) None[source]¶
Compute the action of this
Operatoron an input state and accumulate into the output state.- Parameters
t – Time argument to be passed to all callback functions.
params – Additional arguments to be passed to all callback functions.
state – The input quantum state to which the
Operatoris to be applied.state_out – The output quantum state to which the action is to be accumulated. Defaults to
state.
- compute_expectation(t: float, params: Sequence[float], state: State) cupy.ndarray[source]¶
Compute the expectation value of this
Operatoron a state.- Parameters
t – Time argument to be passed to all callback functions.
params – Additional arguments to be passed to all callback functions.
state – The quantum state on which the expectation value is evaluated.
- Returns
The computed expectation value wrapped in a
cupy.ndarray.
Note
Currently, this method executes in blocking manner, returning the expectation value only after the computation is finished.
- dual() Operator[source]¶
Return a shallow, partial copy of this
Operatorwith flipped duality for each term.
- prepare_action(ctx: WorkStream, state: State, state_out: Optional[State] = None, compute_type: Optional[str] = None) None[source]¶
Prepare the action of this
Operatoron an input state and accumulate into the output state.- Parameters
ctx – Library context, which contains workspace, stream and other configuration information.
state – The input quantum state to which the
Operatoris to be applied.state_out – The output quantum state to which the action is to be accumulated. Defaults to
state.compute_type – The CUDA compute type to be used by the computation.
Attention
The
compute_typeargument is currently not used and will default to the data type.
- prepare_expectation(ctx: WorkStream, state: State, compute_type: Optional[str] = None) None[source]¶
Prepare the computation of an expectation value of this
Operatoron a state.- Parameters
ctx – Library context, which contains workspace, stream and other configuration information.
state – The quantum state on which the expectation value is evaluated.
compute_type – The CUDA compute type to be used by the computation.
Attention
The
compute_typeargument is currently not used and will default to the data type.
Attributes