XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ dgssvd()

void dgssvd ( char  jobv,
char  jobu,
int  m,
int  n,
const double  val[],
const int  ptr[],
const int  ind[],
int  base,
int  format,
double  s[],
const char *  which,
int  nev,
double  tol,
double  resid[],
int  ncv,
int  ldv,
double  v[],
int  ldu,
double  u[],
int  maxiter,
double  workd[],
double  workl[],
int  lworkl,
double  workv[],
int  iwork[],
int *  info 
)

Singular value decomposition (SVD) of a general sparse matrix (driver)

Purpose
The singular values (s) and corresponding right singular vectors (v) for the the matrix A are computed by solving the symmetric eigenvalue problem:
(A^T*A)*v = s^2*v
where A is an m by n real general sparse matrix. The left singular vectors are also computed by u = A*v/s if required.

The sparse matrix is stored in CSC or CSR format.

The eigenvalue problem is solved by the implicitly restarted Lanczos method (IRLM) using arpack routines dsaupd and dseupd.
Parameters
[in]jobv= 'N': Do not compute right singular vector(s).
= 'V': Compute right singular vector(s).
[in]jobu= 'N': Do not compute left singular vector(s).
= 'U': Compute left singular vector(s). (jobv must also be 'V'.)
[in]mNumber of rows of the matrix. (m >= 0) (If m = 0, returns without computation)
[in]nNumber of columns of the matrix. (n >= 0) (If n = 0, returns without computation)
[in]val[]Array val[lval] (lval >= nnz)
Values of nonzero elements of input matrix (where nnz is the number of nonzero elements).
[in]ptr[]Array ptr[lptr] (lptr >= n + 1)
Column pointers (if CSC) or row pointers (if CSR) of input matrix.
[in]ind[]Array ind[lind] (lind >= nnz)
Row indices (if CSC) or column indices (if CSR) of input matrix (where nnz is the number of nonzero elements).
[in]baseIndexing of ptr[] and ind[].
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.
[in]formatSparse matrix format.
= 0: CSR format.
= 1: CSC format.
[out]s[]Array s[ls] (ls >= nev)
Contains the singular values of A. The values are returned in ascending order.
[in]which= "LA": Compute the nev largest (algebraic) singular values.
= "SA": Compute the nev smallest (algebraic) singular values.
= "LM": Compute the nev largest (in magnitude) singular values.
= "SM": Compute the nev smallest (in magnitude) singular values.
= "BE": Compute nev singular values, half from each end of the spectrum. When nev is odd, compute one more from the high end than from the low end.
[in]nevNumber of singular values to be computed. (0 < nev < n)
[in]tolStopping criterion: the acceptable relative accuracy of the Ritz value. If tol <= 0, machine precision is assumed.
[out]resid[]Array resid[lresid] (lresid >= n)
The residual vector.
[in]ncvThis will indicate how many Lanczos vectors are generated at each iteration. (nev < ncv <= n) (ncv >= 2*nev is recommended)
[in]ldvLeading dimension of the array v. (ldv >= n)
[out]v[]Array v[ldv * lv] (lv >= nev)
nev right singular vectors. Not referenced if jobv = 'N'.
[in]lduLeading dimension of the array u. (ldu >= m)
[out]u[]Array u[ldu * lu] (lu >= nev)
nev left singular vectors. Not referenced if jobu = 'N'.
[in]maxiterMaximum number of Lanczos update iterations allowed.
[out]workd[]Array workd[lworkd] (lworkd >= 3*n)
Distributed work array used for reverse communication.
[out]workl[]Array workl[lworkl]
Local work array.
[in]lworklSize of array workl[]. (lworkl >= ncv^2 + 8*ncv)
[out]workv[]Array workv[lworkv] (lworkv >= n*ncv)
Double work array.
[out]iwork[]Array iwork[liwork] (liwork >= max(ncv, 3))
Integer work array.
The following values are returned in iwork[0], ..., iwork[2].
iwork[0]: Number of Lanczos update iterations taken.
iwork[1]: Number of Ritz values that satisfy the convergence criterion (nconv).
iwork[2]: Total number of OP*x operations (numop).
[out]infoReturn code.
= 0: Successful exit.
< 0: The (-info)-th argument is invalid.
= 1: Maximum number of iterations taken.
= 3: No shifts could be applied during a cycle of the implicitly restarted Lanczos iteration. A possible remedy is to increase ncv relative to nev (ncv >= 2*nev is recommended).
= 11: Initial residual vector is zero.
= 12: Failed to build a Lanczos factorization.
= 13: Error return from LAPACK eigenvalue calculation.
= 14: dsaupd did not find any eigenvalues to sufficient accuracy.
= 15, 16: Internal code error.