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