Singular value decomposition

Overview

gesvd and the bidiagonal pipeline stages.

Lower-level functions (algorithm-specific variants, workspace queries, validation and helpers): SVD: lower-level API.

Functions

◆ gesvd() [1/4]

template<Backend B, typename T>
Event batchlas::gesvd ( Queue & ctx,
const MatrixView< T, MatrixFormat::Dense > & A,
Span< typename base_type< T >::type > singular_values,
const MatrixView< T, MatrixFormat::Dense > & U,
const MatrixView< T, MatrixFormat::Dense > & Vh,
SvdVectors jobu,
SvdVectors jobvh,
Span< std::byte > workspace,
Span< int32_t > info )

Singular value decomposition of a batch of matrices (LAPACK ?gesvd).

Computes \( A = U \Sigma V^H \) for every m x n batch item, with the \( k = \min(m, n) \) singular values in descending order. The kernel family is the first entry of the nearest row of the device's tuned table (tuned/gesvd.<device>.txt) that can run the call: jacobi (one-sided Jacobi, max(m, n) <= 64, or 32 for complex<double> with vectors), cta (max(m, n) <= 32; no Thin request that canonicalisation leaves thin), blocked (bidiagonalisation for real input; square Hermitian Lower input of any type runs syev_blocked()), or vendor, the solver library. Complex general input therefore runs jacobi or vendor. Pin a family with BATCHLAS_GESVD_ROUTE (e.g. jacobi, vendor). Asynchronous: returns once the work is enqueued.

Parameters
ctxqueue the work is enqueued on
Abatch of m x n matrices; overwritten (destroyed)
singular_valuesk real singular values per batch item, packed, descending
Uleft singular vectors: m x m for SvdVectors::All, m x k for Thin; unused for None
Vh\( V^H \): n x n for All, k x n for Thin; unused for None
jobuwhich columns of U to compute
jobvhwhich rows of Vh to compute
workspaceat least gesvd_buffer_size() bytes for the same arguments
infoper-item convergence status: 0 converged, > 0 LAPACK-like (the number of off-diagonals that failed to converge, or 1 where the kernel that ran tracks only the fact of failure). An EMPTY span means "not requested" and costs nothing; gesvd_buffer_size() is the same either way.
Returns
event of the last enqueued kernel
Exceptions
batchlas::workspace_errorif the workspace span is smaller than the chosen kernel needs
batchlas::NoRouteErrorwhen no native kernel can run the call in a build without the solver library
batchlas::unsupportedif the vendor family runs a shape its binding cannot take: on CUDA (gesvdjBatched) max(m, n) > 32, a non-packed batch stride or a thin request; on ROCm always (no binding). Complex general input above jacobi's ceiling therefore has no kernel on those backends.
batchlas::convergence_erroron NETLIB when an item fails to converge and info is empty (with info given, the status is written instead)
std::invalid_argumentif BATCHLAS_GESVD_ROUTE names a family that is not compiled or cannot run this call (the words native and vendor instead fall back to the tuned choice with a warning)
See also
Kernel selection tables, GESVD, gesvd design, docs/cpp-api.md (convergence status)

◆ gesvd() [2/4]

template<Backend B, typename T>
Event batchlas::gesvd ( Queue & ctx,
const MatrixView< T, MatrixFormat::Dense > & A,
Span< typename base_type< T >::type > singular_values,
const MatrixView< T, MatrixFormat::Dense > & U,
const MatrixView< T, MatrixFormat::Dense > & Vh,
SvdVectors jobu,
SvdVectors jobvh,
Uplo hermitian_uplo,
Span< std::byte > workspace,
Span< int32_t > info )

gesvd() of square Hermitian input.

Other parameters as for the general form.

The native kernels solve it as an eigenproblem (syev_cta() or syev_blocked()) and read only the hermitian_uplo triangle (blocked takes Lower only). The vendor family has no triangle argument and reads all of A, so keep both triangles valid wherever that family can be chosen, e.g. Upper with n > 32.

Precondition
A is square

◆ gesvd() [3/4]

template<Backend B, typename T>
Event batchlas::gesvd ( Queue & ctx,
const MatrixView< T, MatrixFormat::Dense > & A,
Span< typename base_type< T >::type > singular_values,
const MatrixView< T, MatrixFormat::Dense > & U,
const MatrixView< T, MatrixFormat::Dense > & Vh,
SvdVectors jobu,
SvdVectors jobvh,
Span< std::byte > workspace )
inline

gesvd() without the convergence status (info empty).

Definition at line 147 of file gesvd.hh.

◆ gesvd() [4/4]

template<Backend B, typename T>
Event batchlas::gesvd ( Queue & ctx,
const MatrixView< T, MatrixFormat::Dense > & A,
Span< typename base_type< T >::type > singular_values,
const MatrixView< T, MatrixFormat::Dense > & U,
const MatrixView< T, MatrixFormat::Dense > & Vh,
SvdVectors jobu,
SvdVectors jobvh,
Uplo hermitian_uplo,
Span< std::byte > workspace )
inline

Hermitian gesvd() without the convergence status (info empty).

Definition at line 160 of file gesvd.hh.

Topics

 SVD: lower-level API
 The stages and algorithm-specific entry points behind gesvd (gebrd, bdsqr, bdsdc, ormbr, blocked, CTA and Jacobi SVD) and their workspace queries.

Classes

struct  batchlas::GesvdjParams< T >
 Parameters for the one-sided Jacobi SVD (gesvdj_cta). More...