1CGELS(1) LAPACK driver routine (version 3.2) CGELS(1)
2
3
4
6 CGELS - solves overdetermined or underdetermined complex linear systems
7 involving an M-by-N matrix A, or its conjugate-transpose, using a QR or
8 LQ factorization of A
9
11 SUBROUTINE CGELS( TRANS, M, N, NRHS, A, LDA, B, LDB, WORK, LWORK, INFO
12 )
13
14 CHARACTER TRANS
15
16 INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS
17
18 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
19
21 CGELS solves overdetermined or underdetermined complex linear systems
22 involving an M-by-N matrix A, or its conjugate-transpose, using a QR or
23 LQ factorization of A. It is assumed that A has full rank. The fol‐
24 lowing options are provided:
25 1. If TRANS = 'N' and m >= n: find the least squares solution of
26 an overdetermined system, i.e., solve the least squares problem
27 minimize || B - A*X ||.
28 2. If TRANS = 'N' and m < n: find the minimum norm solution of
29 an underdetermined system A * X = B.
30 3. If TRANS = 'C' and m >= n: find the minimum norm solution of
31 an undetermined system A**H * X = B.
32 4. If TRANS = 'C' and m < n: find the least squares solution of
33 an overdetermined system, i.e., solve the least squares problem
34 minimize || B - A**H * X ||.
35 Several right hand side vectors b and solution vectors x can be handled
36 in a single call; they are stored as the columns of the M-by-NRHS right
37 hand side matrix B and the N-by-NRHS solution matrix X.
38
40 TRANS (input) CHARACTER*1
41 = 'N': the linear system involves A;
42 = 'C': the linear system involves A**H.
43
44 M (input) INTEGER
45 The number of rows of the matrix A. M >= 0.
46
47 N (input) INTEGER
48 The number of columns of the matrix A. N >= 0.
49
50 NRHS (input) INTEGER
51 The number of right hand sides, i.e., the number of columns of
52 the matrices B and X. NRHS >= 0.
53
54 A (input/output) COMPLEX array, dimension (LDA,N)
55 On entry, the M-by-N matrix A. if M >= N, A is overwritten by
56 details of its QR factorization as returned by CGEQRF; if M <
57 N, A is overwritten by details of its LQ factorization as
58 returned by CGELQF.
59
60 LDA (input) INTEGER
61 The leading dimension of the array A. LDA >= max(1,M).
62
63 B (input/output) COMPLEX array, dimension (LDB,NRHS)
64 On entry, the matrix B of right hand side vectors, stored
65 columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS if
66 TRANS = 'C'. On exit, if INFO = 0, B is overwritten by the
67 solution vectors, stored columnwise: if TRANS = 'N' and m >= n,
68 rows 1 to n of B contain the least squares solution vectors;
69 the residual sum of squares for the solution in each column is
70 given by the sum of squares of the modulus of elements N+1 to M
71 in that column; if TRANS = 'N' and m < n, rows 1 to N of B con‐
72 tain the minimum norm solution vectors; if TRANS = 'C' and m >=
73 n, rows 1 to M of B contain the minimum norm solution vectors;
74 if TRANS = 'C' and m < n, rows 1 to M of B contain the least
75 squares solution vectors; the residual sum of squares for the
76 solution in each column is given by the sum of squares of the
77 modulus of elements M+1 to N in that column.
78
79 LDB (input) INTEGER
80 The leading dimension of the array B. LDB >= MAX(1,M,N).
81
82 WORK (workspace/output) COMPLEX array, dimension (MAX(1,LWORK))
83 On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
84
85 LWORK (input) INTEGER
86 The dimension of the array WORK. LWORK >= max( 1, MN + max(
87 MN, NRHS ) ). For optimal performance, LWORK >= max( 1, MN +
88 max( MN, NRHS )*NB ). where MN = min(M,N) and NB is the opti‐
89 mum block size. If LWORK = -1, then a workspace query is
90 assumed; the routine only calculates the optimal size of the
91 WORK array, returns this value as the first entry of the WORK
92 array, and no error message related to LWORK is issued by
93 XERBLA.
94
95 INFO (output) INTEGER
96 = 0: successful exit
97 < 0: if INFO = -i, the i-th argument had an illegal value
98 > 0: if INFO = i, the i-th diagonal element of the triangular
99 factor of A is zero, so that A does not have full rank; the
100 least squares solution could not be computed.
101
102
103
104 LAPACK driver routine (version 3.N2o)vember 2008 CGELS(1)