utils

Various utilities used by the rest of the library.

HT

Hermitian conjugate of the input array.

n_slice

Number of elements returned by a slice, assuming a very long array.

block_svd

Completes a block singular-value decomposition.

normalize_SV

Normalises the input array and prints the norm in the logs.

temfpy.utils.HT(M)[source]

Hermitian conjugate of the input array.

Return type:

ndarray

temfpy.utils.n_slice(x)[source]

Number of elements returned by a slice, assuming a very long array.

Return type:

int

temfpy.utils.block_svd(CLR, vL, vR, e, degeneracy_tol=1e-12, overwrite=True)[source]

Completes a block singular-value decomposition.

Assuming the matrix \(v_L^\dagger C_{LR} v_R\) is block diagonal, performs the SVD of each block to obtain singular vectors of CLR.

Blocks are delineated by approximately-equal values of e.

Parameters:
  • CLR (ndarray (N, M)) – The matrix whose SVD is sought.

  • vL (ndarray (N, K)) – The left almost-singular vectors of CLR.

  • vR (ndarray (M, K)) – The right almost-singular vectors of CLR.

  • e (ndarray (K,)) – Eigenvalues used to delineate blocks.

  • degeneracy_tol (float) –

    Threshold for considering consecutive entries of e equal.

    Rows/columns i and i+1 are assumed to be in different blocks if abs(e[i] - e[i+1]) > degeneracy_tol.

  • overwrite (bool) – Overwrite vL and vR with the signular vectors (default: True).

Return type:

tuple[ndarray, ndarray]

Returns:

The singular vectors of CLR.

temfpy.utils.normalize_SV(λ, logger)[source]

Normalises the input array and prints the norm in the logs.

Return type:

ndarray