sun_diffusion.sun module¶
Utilities for group/algebra operations with and between SU(N) variables.
- sun_diffusion.sun.matrix_exp(A)¶
Applies the complex exponential map to a Hermitian matrix A.
- Return type:
Tensor
- sun_diffusion.sun.matrix_log(U)¶
Computes the matrix logarithm on a special unitary matrix U.
- Return type:
Tensor
- sun_diffusion.sun.proj_to_algebra(A)¶
Projects a complex-valued matrix A into the \({\rm SU}(N)\) Lie algebra by converting it into a traceless, Hermitian matrix.
- Parameters:
A (Tensor) – Batch of complex-valued square matrices
- Return type:
Tensor- Returns:
Projection of A into \(\mathfrak{su}(N)\)
- sun_diffusion.sun.random_sun_element(batch_size, *, Nc, scale=1.0)¶
Samples a batch of \({\rm SU}(N)\) matrices that are the exponential of \(\mathfrak{su}(N)\) elements randomly drawn from a standard normal distribution.
- Parameters:
batch_size (int) – Number of matrices to generate
Nc (int) – Dimension of each matrix
scale (float) – Width of the normal density. Default: 1.0
- Return type:
Tensor- Returns:
Batch of random \({\rm SU}(N)\) matrices as PyTorch tensors
- sun_diffusion.sun.random_un_haar_element(batch_size, *, Nc)¶
Creates a batch of Haar-random \({\rm U}(N)\) matrices.
- Parameters:
batch_size (int) – Number of matrices to generate
Nc (int) – Dimension of each matrix
- Return type:
Tensor- Returns:
Batch of random \({\rm U}(N)\) matrices as PyTorch tensors
- sun_diffusion.sun.random_sun_lattice(batch_shape, *, Nc)¶
Creates a collection of random \({\rm SU}(N)\) matrices with arbitrary batch dimension specified by batch_shape.
- Parameters:
batch_shape (tuple) – Desired shape of batch to generate
Nc (int) – Matrix dimension
- Return type:
Tensor- Returns:
Tensor of matrices with shape [*batch_shape, Nc, Nc]
- sun_diffusion.sun.inner_prod(U, V)¶
Computes the inner product between two Lie algebra matrices U and V.
The inner product on \(\mathfrak{su}(N)\) is defined as
\[\langle U, V \rangle := {\rm Tr}(U^\dagger V)\]- Parameters:
U (Tensor) – Batch of traceless, Hermitian matrices
V (Tensor) – Batch of traceless, Hermitian matrices
- Return type:
Tensor- Returns:
Inner product between U and V as a batch of real scalars
- sun_diffusion.sun.embed_sun_algebra(omega, Nc)¶
Constructs a matrix in \(\mathfrak{su}(N)\) from coeffs omega.
- Return type:
Tensor
- sun_diffusion.sun.extract_sun_algebra(A)¶
Returns the coeffs from a matrix A in \(\mathfrak{su}(N)\).
- Return type:
Tensor
- sun_diffusion.sun.group_to_coeffs(U)¶
Decomposes an \({\rm SU}(N)\) matrix into the coefficients on the generators in the algebra \(\mathfrak{su}(N)\).
- Parameters:
U (Tensor) – Batch of \({\rm SU}(N)\) matrices
- Return type:
Tensor- Returns:
Batch of \(N^2 - 1\) generator coefficients
- sun_diffusion.sun.coeffs_to_group(coeffs)¶
Recomposes an \({\rm SU}(N)\) matrix given generator coefficients.
The group element is reconstructed by forming the linear combination with the generators in \(\mathfrak{su}(N)\), and then exponentiating onto the group manifold:
\[U = \exp\left(\sum_a c_a T_a\right)\]- Parameters:
coeffs (Tensor) – Batch of \(N^2 - 1\) generator coefficients
- Return type:
Tensor- Returns:
Batch of \({\rm SU}(N)\) matrices
- sun_diffusion.sun.mat_angle(U)¶
Eigen-decomposes a matrix U to get its eigenangles and eigenvectors.
- Parameters:
U (Tensor) – Input matrix to decompose
- Return type:
tuple[Tensor,Tensor,Tensor]- Returns:
Tuple of (eigengangles, matrix of eigenvectors, inverse eigenvector matrix)
- sun_diffusion.sun.extract_diag(M)¶
Extracts the diagonal entries of M as (…, n, n) -> (…, n).
- Return type:
Tensor
- sun_diffusion.sun.embed_diag(d)¶
Embeds a batch of diagonal entries d as (…, n) -> (…, n, n).
- Return type:
Tensor