cuquantum.densitymat.OperatorTerm¶
- class cuquantum.densitymat.OperatorTerm(dtype: Optional[str] = None)[source]¶
Operator term consisting of tensor products of elementary operators.
An
OperatorTerm
containing 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 (+
) ofOperatorTerm
objects.- Parameters
dtype – Numeric data type of the underlying elementary operators’ data. Defaults to
None
and will be inferred from the appended tensor products of elementary operators.
Note
Scalar operators, for which no product is appended, require specification of
dtype
at construction.
Methods
- __add__(other: OperatorTerm) OperatorTerm [source]¶
Return a new
OperatorTerm
equal to the sum of thisOperatorTerm
and anotherOperatorTerm
.
- __iadd__(other: OperatorTerm) OperatorTerm [source]¶
Inplace add another
OperatorTerm
into 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[Union[numpy.ndarray, cupy.ndarray], Callback], OperatorTerm]) OperatorTerm [source]¶
Multiply this
OperatorTerm
with 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_size
as the output of the callable.
- __rmul__(other: Union[numbers.Number, numpy.ndarray, cupy.ndarray, Callback, Tuple[Union[numpy.ndarray, cupy.ndarray], Callback], OperatorTerm]) OperatorTerm [source]¶
Multiply this
OperatorTerm
with a number, callable or anotherOperatorTerm
on 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[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_ops
is 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[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_ops
is matrix multiplication.
- dag() OperatorTerm [source]¶
Return a new
OperatorTerm
equal to the complex conjugate of thisOperatorTerm
.Warning
A error will be raised if the
OperatorTerm
contains tensor products of elementary operators acting on both bra and ket modes at the same time.
- dual() OperatorTerm [source]¶
Return a new
OperatorTerm
with duality reversed.
Attributes
- dtype¶
Data type of this
OperatorTerm
.
- hilbert_space_dims¶
Hilbert space dimensions of this
OperatorTerm
.