qrunch.common.arrays.array_protocols

Module for implementing protocols for arrays.

Classes

Array

Protocol for implementing arrays.

RotationBlockDefinition

Represents the slice of a block of a rotation matrix.

class Array

Bases: HasMetadataHashMethod, Protocol

Protocol for implementing arrays.

property H: Array

Return the Hermitian conjugate of the Array.

property T: Array

Return the transpose of the Array.

__init__(*args, **kwargs)
compare(other: Array) bool

Return True, if equal to other array.

Parameters:

other (Array)

Return type:

bool

conjugate() Array

Conjugate all elements.

Return type:

Array

is_hermitian() bool

Return true if the array is Hermitian.

Return type:

bool

property n_nonzero: int

Return the number of non-zero elements.

property ndim: int

Dimension of the array.

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

Rotate the array with the given rotation matrix.

Parameters:

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

Return type:

Self

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 Array.

class RotationBlockDefinition

Bases: object

Represents the slice of a block of a rotation matrix.

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

Parameters:

shape – Shape of the rotation matrix.

__init__(shape: tuple[int, int]) None
Parameters:

shape (tuple[int, int])

Return type:

None

n_free_params() int

Get the amount of free parameters in the block.

Return type:

int

shape: tuple[int, int]
property size: int

Get the size of the block.