svdpi#

Perform a singular value decomposition (SVD) using the power iteration method. This method is usually better than svd where the matrices are small and batches are large

template<typename AType, typename X0Type>
__MATX_INLINE__ auto matx::svdpi(AType &A, X0Type &x0, int iterations, index_t k = -1)#

Perform a SVD decomposition using the power iteration. This version of SVD works well on small n/m with large batch.

Template Parameters:
  • AType – Tensor or operator type for output of A input tensors.

  • X0Type – Tensor or operator type for X0 initial guess in power iteration.

Parameters:
  • A – Input tensor or operator for tensor A input with size “batches by m by n”

  • x0 – Input tensor or operator signaling the initial guess for x0 at each power iteration. A Random tensor of size batches x min(n,m) is suggested.

  • iterations – The number of power iterations to perform for each singular value.

  • k – The number of singular values to find. Default is all singular values: min(m,n).

Examples#

auto A = make_tensor<AType>(Ashape);
auto U = make_tensor<AType>(Ushape);
auto VT = make_tensor<AType>(VTshape);
auto S = make_tensor<SType>(Sshape);

int iterations = 100;

(A = random<AType>(AshapeA, NORMAL)).run(exec);
auto x0 = random<SType>(std::move(Sshape), NORMAL);

(U = 0).run(exec);
(S = 0).run(exec);
(VT = 0).run(exec);

(mtie(U, S, VT) = svdpi(A, x0, iterations, r)).run(exec);