t3toolbox.backend.linalg.right_svd_3tensor#

t3toolbox.backend.linalg.right_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 right unfolding.

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

G0_i_a_j = einsum(‘iax,x,xj->ixj’, U_i_x, ss_x, Vt_x_a_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_x (NDArray) – Left singular vectors. shape=(ni, nx). einsum(‘ix,iy->xy’, U_i_x, U_i_x) = identity matrix

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

  • Vt_x_a_j (NDArray) – Right singular vectors, reshaped into 3-tensor. shape=(nx, na, nj) einsum(‘xaj,yaj->xy’, Vt_x_a_j, Vt_x_a_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, left_svd_3tensor, outer_svd_3tensor, right_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_x, ss_x, Vt_x_a_j = orth.right_svd_3tensor(G_i_a_j)
>>> G_i_a_j2 = np.einsum('ix,x,xaj->iaj', U_i_x, ss_x, Vt_x_a_j)
>>> print(np.linalg.norm(G_i_a_j - G_i_a_j2)) # SVD exact to numerical precision
1.2503321403334437e-14
>>> rank = len(ss_x)
>>> print(np.linalg.norm(np.einsum('ix,iy->xy', U_i_x, U_i_x) - np.eye(rank))) # U is orthogonal
1.6591938592301729e-15
>>> print(np.linalg.norm(np.einsum('xaj,yaj->xy', Vt_x_a_j, Vt_x_a_j) - np.eye(rank))) # Vt is right-orthogonal
1.9466202162000267e-15