1CGELSD(1) LAPACK driver routine (version 3.2) CGELSD(1)
2
3
4
6 CGELSD - computes the minimum-norm solution to a real linear least
7 squares problem
8
10 SUBROUTINE CGELSD( M, N, NRHS, A, LDA, B, LDB, S, RCOND, RANK, WORK,
11 LWORK, RWORK, IWORK, INFO )
12
13 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, RANK
14
15 REAL RCOND
16
17 INTEGER IWORK( * )
18
19 REAL RWORK( * ), S( * )
20
21 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
22
24 CGELSD computes the minimum-norm solution to a real linear least
25 squares problem:
26 minimize 2-norm(| b - A*x |)
27 using the singular value decomposition (SVD) of A. A is an M-by-N
28 matrix which may be rank-deficient.
29 Several right hand side vectors b and solution vectors x can be handled
30 in a single call; they are stored as the columns of the M-by-NRHS right
31 hand side matrix B and the N-by-NRHS solution matrix X.
32 The problem is solved in three steps:
33 (1) Reduce the coefficient matrix A to bidiagonal form with
34 Householder tranformations, reducing the original problem
35 into a "bidiagonal least squares problem" (BLS)
36 (2) Solve the BLS using a divide and conquer approach.
37 (3) Apply back all the Householder tranformations to solve
38 the original least squares problem.
39 The effective rank of A is determined by treating as zero those singu‐
40 lar values which are less than RCOND times the largest singular value.
41 The divide and conquer algorithm makes very mild assumptions about
42 floating point arithmetic. It will work on machines with a guard digit
43 in add/subtract, or on those binary machines without guard digits which
44 subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. It could
45 conceivably fail on hexadecimal or decimal machines without guard dig‐
46 its, but we know of none.
47
49 M (input) INTEGER
50 The number of rows of the matrix A. M >= 0.
51
52 N (input) INTEGER
53 The number of columns of the matrix A. N >= 0.
54
55 NRHS (input) INTEGER
56 The number of right hand sides, i.e., the number of columns of
57 the matrices B and X. NRHS >= 0.
58
59 A (input/output) COMPLEX array, dimension (LDA,N)
60 On entry, the M-by-N matrix A. On exit, A has been destroyed.
61
62 LDA (input) INTEGER
63 The leading dimension of the array A. LDA >= max(1,M).
64
65 B (input/output) COMPLEX array, dimension (LDB,NRHS)
66 On entry, the M-by-NRHS right hand side matrix B. On exit, B
67 is overwritten by the N-by-NRHS solution matrix X. If m >= n
68 and RANK = n, the residual sum-of-squares for the solution in
69 the i-th column is given by the sum of squares of the modulus
70 of elements n+1:m in that column.
71
72 LDB (input) INTEGER
73 The leading dimension of the array B. LDB >= max(1,M,N).
74
75 S (output) REAL array, dimension (min(M,N))
76 The singular values of A in decreasing order. The condition
77 number of A in the 2-norm = S(1)/S(min(m,n)).
78
79 RCOND (input) REAL
80 RCOND is used to determine the effective rank of A. Singular
81 values S(i) <= RCOND*S(1) are treated as zero. If RCOND < 0,
82 machine precision is used instead.
83
84 RANK (output) INTEGER
85 The effective rank of A, i.e., the number of singular values
86 which are greater than RCOND*S(1).
87
88 WORK (workspace/output) COMPLEX array, dimension (MAX(1,LWORK))
89 On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
90
91 LWORK (input) INTEGER
92 The dimension of the array WORK. LWORK must be at least 1. The
93 exact minimum amount of workspace needed depends on M, N and
94 NRHS. As long as LWORK is at least 2 * N + N * NRHS if M is
95 greater than or equal to N or 2 * M + M * NRHS if M is less
96 than N, the code will execute correctly. For good performance,
97 LWORK should generally be larger. If LWORK = -1, then a
98 workspace query is assumed; the routine only calculates the
99 optimal size of the array WORK and the minimum sizes of the
100 arrays RWORK and IWORK, and returns these values as the first
101 entries of the WORK, RWORK and IWORK arrays, and no error mes‐
102 sage related to LWORK is issued by XERBLA.
103
104 RWORK (workspace) REAL array, dimension (MAX(1,LRWORK))
105 LRWORK >= 10*N + 2*N*SMLSIZ + 8*N*NLVL + 3*SMLSIZ*NRHS + (SML‐
106 SIZ+1)**2 if M is greater than or equal to N or 10*M + 2*M*SML‐
107 SIZ + 8*M*NLVL + 3*SMLSIZ*NRHS + (SMLSIZ+1)**2 if M is less
108 than N, the code will execute correctly. SMLSIZ is returned by
109 ILAENV and is equal to the maximum size of the subproblems at
110 the bottom of the computation tree (usually about 25), and NLVL
111 = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 ) On exit,
112 if INFO = 0, RWORK(1) returns the minimum LRWORK.
113
114 IWORK (workspace) INTEGER array, dimension (MAX(1,LIWORK))
115 LIWORK >= max(1, 3*MINMN*NLVL + 11*MINMN), where MINMN = MIN(
116 M,N ). On exit, if INFO = 0, IWORK(1) returns the minimum
117 LIWORK.
118
119 INFO (output) INTEGER
120 = 0: successful exit
121 < 0: if INFO = -i, the i-th argument had an illegal value.
122 > 0: the algorithm for computing the SVD failed to converge;
123 if INFO = i, i off-diagonal elements of an intermediate bidiag‐
124 onal form did not converge to zero.
125
127 Based on contributions by
128 Ming Gu and Ren-Cang Li, Computer Science Division, University of
129 California at Berkeley, USA
130 Osni Marques, LBNL/NERSC, USA
131
132
133
134 LAPACK driver routine (version 3.N2o)vember 2008 CGELSD(1)