up_svd#

t3toolbox.backend.linalg.up_svd(G0_i_a_j, min_rank=None, max_rank=None, rtol=None, atol=None)#
def up_svd(
        G0_i_a_j: NDArray, # shape=(ni, na, nj)
        min_rank: int = None, # 1 <= min_rank <= max_rank <= minimum(ni*na, nj)
        max_rank: int = None, # 1 <= min_rank <= max_rank <= minimum(ni*na, nj)
        rtol: float = None, # removes singular values satisfying sigma < maximum(atol, rtol*sigma1)
        atol: float = None, # removes singular values satisfying sigma < maximum(atol, rtol*sigma1)
) -> typ.Tuple[
    NDArray, # U_i_x_j, shape=(ni, nx, nj),
    NDArray, # ss_x,    shape=(nx,)
    NDArray, # Vt_x_a,  shape=(nx, na)
]:

Compute (truncated) singular value decomposition of 3-tensor up unfolding.

First and last indices of the tensor are grouped to form rows for the SVD; the middle index forms columns: G[i,a,j] = sum_x U[i,x,j] ss[x] Vt[x,a], with U orthonormal in its grouped (i,j) rows. Truncation args behave as in truncated_svd().

Examples

>>> import numpy as np
>>> import t3toolbox.backend.linalg as linalg
>>> np.random.seed(0)
>>> G = np.random.randn(4, 5, 6)                      # (ni, na, nj)
>>> U, ss, Vt = linalg.up_svd(G)
>>> print(U.shape, ss.shape, Vt.shape)               # U keeps (i,j) on either side of x; Vt is 2d
(4, 5, 6) (5,) (5, 5)
>>> print(np.allclose(np.einsum('ixj,x,xa->iaj', U, ss, Vt), G))   # reconstructs G
True
>>> Um = U.transpose(0, 2, 1).reshape(4 * 6, -1)
>>> print(np.allclose(Um.T @ Um, np.eye(Um.shape[1])))   # up unfolding of U is orthonormal
True
Parameters:
  • G0_i_a_j (NDArray)

  • min_rank (int)

  • max_rank (int)

  • rtol (float)

  • atol (float)

Return type:

t3toolbox.backend.common.typ.Tuple[NDArray, NDArray, NDArray]