t3toolbox.backend.linalg.left_svd_3tensor#

t3toolbox.backend.linalg.left_svd_3tensor(G0_i_a_j: NDArray, min_rank: int = None, max_rank: int = None, rtol: float = None, atol: float = None, use_jax: bool = False) t3toolbox.backend.common.typ.Tuple[NDArray, NDArray, NDArray]#

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

First two indices of the tensor are grouped for the SVD.

G0_i_a_j = einsum(‘iax,x,xj->ixj’, U_i_a_x, ss_x, Vt_x_j). Equality may be approximate if truncation is used.

Parameters:
  • G0_i_a_j (NDArray) – 3-tensor. shape=(ni, na, nj)

  • min_rank (int) – Minimum rank for truncation.

  • min_rank – Maximum rank for truncation.

  • rtol (float) – Relative tolerance for truncation.

  • atol (float) – Absolute tolerance for truncation.

  • xnp – Linear algebra backend. Default: np (numpy)

Returns:

  • U_i_a_x (NDArray) – Left singular vectors, reshaped into 3-tensor. shape=(ni, na, nx). einsum(‘iax,iay->xy’, U_i_a_x, U_i_a_x) = identity matrix

  • ss_x (NDArray) – Singular values. Non-negative. shape=(nx,).

  • Vt_x_j (NDArray) – Right singular vectors. shape=(nx, nj) einsum(‘xj,yj->xy’, Vt_x_j, Vt_x_j) = identity matrix

Raises:

RuntimeError – Error raised if the provided indices in index are inconsistent with each other or the Tucker tensor train x.

See also

truncated_svd, right_svd_3tensor, outer_svd_3tensor, left_svd_ith_tt_core, t3_svd

Examples

>>> import numpy as np
>>> import t3toolbox.orthogonalization as orth
>>> G_i_a_j = np.random.randn(5,7,6)
>>> U_i_a_x, ss_x, Vt_x_j = orth.left_svd_3tensor(G_i_a_j)
>>> G_i_a_j2 = np.einsum('iax,x,xj->iaj', U_i_a_x, ss_x, Vt_x_j)
>>> print(np.linalg.norm(G_i_a_j - G_i_a_j2)) # SVD exact to numerical precision
1.8290510387826402e-14
>>> rank = len(ss_x)
>>> print(np.linalg.norm(np.einsum('iax,iay->xy', U_i_a_x, U_i_a_x) - np.eye(rank))) # U is left-orthogonal
1.6194412284045956e-15
>>> print(np.linalg.norm(np.einsum('xj,yj->xy', Vt_x_j, Vt_x_j) - np.eye(rank))) # V is orthogonal
1.4738004835812172e-15