qrunch.common.arrays.array_protocols
Module for implementing protocols for arrays.
Classes
Protocol for implementing arrays. |
|
Represents the slice of a block of a rotation matrix. |
- class Array
Bases:
HasMetadataHashMethod,ProtocolProtocol for implementing arrays.
- __init__(*args, **kwargs)
- compare(other: Array) bool
Return True, if equal to other array.
- Parameters:
other (Array)
- Return type:
bool
- 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:
objectRepresents 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.