cuquantum.densitymat.DenseOperator

class cuquantum.densitymat.DenseOperator(data, callback=None)[source]

Dense elementary operator from data buffer and optional callback.

Parameters
  • data – Data buffer for operator elements.

  • callback – A CPU callback function with signature (t, args) -> np.ndarray.

Note

  • A copy will be created on the data buffer and can be accessed through the data attribute.

  • The returned array needs to be consistent with the provided data buffer in terms of shape and data type. The data buffer will be updated when this instance is involved in a compute method of an Operator or OperatorAction.

Examples

>>> import numpy as np
>>> from cuquantum.densitymat import DenseOperator

Suppose we want to construct a creation operator on a Hilbert space of dimension 3 as a DenseOperator. It can be constructed from the data buffer directly as

>>> data = np.array([
>>>     [0, 0, 0],
>>>     [1.0, 0, 0],
>>>     [0, np.sqrt(2), 0],
>>> ])
>>> dense_op = DenseOperator(data)

Methods

__add__(other: Union[DenseOperator, MultidiagonalOperator]) DenseOperator[source]

Add an elementary operator to this instance and return a new DenseOperator.

__init__(data: Union[numpy.ndarray, cupy.ndarray], callback: Optional[Callable[[float, Sequence], numpy.ndarray]] = None) None[source]

Initialize a dense elementary operator from data buffer and optional callback.

__matmul__(other: Union[DenseOperator, MultidiagonalOperator]) DenseOperator[source]

Perform matrix multiplication between this instance and an elementary operator and return a new DenseOperator.

__mul__(scalar: numbers.Number) DenseOperator[source]

Multiply this instance with a scalar on the left.

__rmul__(scalar: numbers.Number) DenseOperator[source]

Multiply this instance with a scalar on the right.

__sub__(other: Union[DenseOperator, MultidiagonalOperator]) DenseOperator[source]

Subtract an elementary operator from this instance and return a new DenseOperator.

copy() DenseOperator[source]

Return a copy of the dense elementary operator.

dag() DenseOperator[source]

Return the conjugate complex transpose of this instance.

to_array(t: Optional[float] = None, args: Optional[Sequence] = None, device: str = 'cpu') Union[numpy.ndarray, cupy.ndarray][source]

Return the array form of the dense elementary operator.

Parameters
  • t – Time variable in callback, only required if callback is not None.

  • args – Additional arguments in callback, only required if callback is not None.

  • device – Device on which to return the array. Defaults to "cpu".

Returns

Array form of the dense elementary operator on the specified device.

Attributes

data

Data buffer of the elementary operator.