cuquantum.densitymat.OperatorTerm¶
- class cuquantum.densitymat.OperatorTerm(dtype: Optional[str] = None)[source]¶
Operator term consisting of tensor products of elementary operators.
An
OperatorTermcontaining a tensor product of elementary operators can be obtained from the free functiontensor_product(). Sums of more than a single product are obtained by in-place (+=) or out-of-place addition (+) ofOperatorTermobjects.- Parameters
dtype – Numeric data type of the underlying elementary operators’ data. Defaults to
Noneand will be inferred from the appended tensor products of elementary operators.
Note
Scalar operators, for which no product is appended, require specification of
dtypeat construction.
Methods
- __add__(other: OperatorTerm) OperatorTerm[source]¶
Return a new
OperatorTermequal to the sum of thisOperatorTermand anotherOperatorTerm.
- __iadd__(other: OperatorTerm) OperatorTerm[source]¶
Inplace add another
OperatorTerminto thisOperatorTerm.
- __init__(dtype: Optional[str] = None)[source]¶
Initialize an operator term consisting of tensor products of elementary operators.
- __mul__(other: Union[numbers.Number, numpy.ndarray, cupy.ndarray, Callback, Tuple[numbers.Number, Callback], Tuple[Union[numpy.ndarray, cupy.ndarray], Callback], OperatorTerm]) OperatorTerm[source]¶
Multiply this
OperatorTermwith another OperatorTerm or with a coefficient. Note that multiplication by a Callable that outputs a batched coefficient vector requires all static coefficients to have the the samebatch_sizeas the output of the callable.
- __rmul__(other: Union[numbers.Number, numpy.ndarray, cupy.ndarray, Callback, Tuple[numbers.Number, Callback], Tuple[Union[numpy.ndarray, cupy.ndarray], Callback], OperatorTerm]) OperatorTerm[source]¶
Multiply this
OperatorTermwith a number, callable or anotherOperatorTermon the right.
- append_elementary_product(elem_ops: Iterable[ElementaryOperator], modes: Iterable[Sequence[int]], duals: Iterable[Sequence[bool]], coeff: Union[numbers.Number, numpy.ndarray, cupy.ndarray, Callback, Tuple[numbers.Number, Callback], Tuple[Union[numpy.ndarray, cupy.ndarray], Callback]] = 1 + 0j, batch_size: int = 1) None[source]¶
Append a product of elementary operators to this operator term.
- Parameters
elem_ops – An iterable of elementary operators.
modes – An iterable of the mode indices of the elementary operators.
duals – Dualities of the elementary operators.
coeff – Coefficient associated with this tensor product of elementary operators.
batch_size – Batch size associated with this product of elementary operators.
Note
The relation among operators in
elem_opsis matrix multiplication/tensor contraction, which is equivalent to tensor product when there are no overlapping modes.
- append_matrix_product(matrix_ops: Iterable[MatrixOperator], conjugations: Iterable[bool], duals: Iterable[bool], coeff: Union[numbers.Number, numpy.ndarray, cupy.ndarray, Callback, Tuple[numbers.Number, Callback], Tuple[Union[numpy.ndarray, cupy.ndarray], Callback]] = 1 + 0j, batch_size: int = 1) None[source]¶
Append a product of matrix operators to this operator term.
- Parameters
matrix_ops – An iterable of matrix operators.
conjugations – An iterable of whether each matrix operator is conjugated.
duals – Dualities of the matrix operators.
coeff – Coefficient associated with this tensor product of matrix operators.
batch_size – Batch size associated with this product of matrix operators.
Note
The relation among operators in
matrix_opsis matrix multiplication.
- dag() OperatorTerm[source]¶
Return a new
OperatorTermequal to the complex conjugate of thisOperatorTerm.Warning
A error will be raised if the
OperatorTermcontains tensor products of elementary operators acting on both bra and ket modes at the same time.
- dual() OperatorTerm[source]¶
Return a new
OperatorTermwith duality reversed.
Attributes
- dtype¶
Data type of this
OperatorTerm.
- hilbert_space_dims¶
Hilbert space dimensions of this
OperatorTerm.