qrunch.common.arrays.dense_array

Wrapped version of a numpy ndarray that has a rotate-method.

Classes

DenseArray

Dense multi-dimensional array.

class DenseArray

Bases: Array, HasCustomEncoding

Dense multi-dimensional array.

All fields are immutable (frozen=True) so an instance can be safely reused.

Parameters:

data – The underlying data of the array.

property H: DenseArray

Return the Hermitian conjugate of the DenseArray.

property T: DenseArray

Return the transpose of the DenseArray.

__init__(data: ndarray[Any, dtype[float64]] | ndarray[Any, dtype[complex128]]) None
Parameters:

data (ndarray[Any, dtype[float64]] | ndarray[Any, dtype[complex128]])

Return type:

None

compare(other: Array) bool

Return True, if equal to other array.

Parameters:

other (Array)

Return type:

bool

conjugate() DenseArray

Conjugate all elements.

Return type:

DenseArray

data: ndarray[Any, dtype[float64]] | ndarray[Any, dtype[complex128]]
classmethod decode(data: dict[str, Any]) DenseArray

Decode a dictionary to an instance of DenseArray.

Parameters:

data (dict[str, Any]) – The dictionary representation of a DenseArray instance.

Return type:

DenseArray

property dtype: type[float64] | type[complex128]

Get type of underlying data.

encode() dict[str, Any]

Encode the instance into a dictionary.

Return type:

dict[str, Any]

is_hermitian() bool

Return true if the dense array is Hermitian.

Return type:

bool

property n_nonzero: int

Return the number of non-zero elements.

property ndim: int

Dimension of the dense array.

rotate(rotation_matrices: tuple[ndarray[Any, dtype[float64]], ...]) DenseArray

Rotate the array with the given rotation matrix.

Parameters:

rotation_matrices (tuple[ndarray[Any, dtype[float64]], ...]) – Tuple of 2-dimensional real symmetric matrix controlling the rotation. Should match the structure given by the output of the rotation_matrix_structure method.

Return type:

DenseArray

rotation_matrix_structure() list[RotationBlockDefinition]

Get information on which blocks should be non-zero in the rotation matrix.

Return type:

list[RotationBlockDefinition]

property shape: tuple[int, ...]

Return the shape of the DenseArray.