1DGELS(1) LAPACK driver routine (version 3.2) DGELS(1)
2
3
4
6 DGELS - solves overdetermined or underdetermined real linear systems
7 involving an M-by-N matrix A, or its transpose, using a QR or LQ fac‐
8 torization of A
9
11 SUBROUTINE DGELS( 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 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), WORK( * )
19
21 DGELS solves overdetermined or underdetermined real linear systems
22 involving an M-by-N matrix A, or its transpose, using a QR or LQ fac‐
23 torization of A. It is assumed that A has full rank. The following
24 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 = 'T' and m >= n: find the minimum norm solution of
31 an undetermined system A**T * X = B.
32 4. If TRANS = 'T' and m < n: find the least squares solution of
33 an overdetermined system, i.e., solve the least squares problem
34 minimize || B - A**T * 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 = 'T': the linear system involves A**T.
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) DOUBLE PRECISION array, dimension (LDA,N)
55 On entry, the M-by-N matrix A. On exit, if M >= N, A is over‐
56 written by details of its QR factorization as returned by DGE‐
57 QRF; if M < N, A is overwritten by details of its LQ factor‐
58 ization as returned by DGELQF.
59
60 LDA (input) INTEGER
61 The leading dimension of the array A. LDA >= max(1,M).
62
63 B (input/output) DOUBLE PRECISION 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 = 'T'. 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 elements N+1 to M in that col‐
71 umn; if TRANS = 'N' and m < n, rows 1 to N of B contain the
72 minimum norm solution vectors; if TRANS = 'T' and m >= n, rows
73 1 to M of B contain the minimum norm solution vectors; if TRANS
74 = 'T' and m < n, rows 1 to M of B contain the least squares
75 solution vectors; the residual sum of squares for the solution
76 in each column is given by the sum of squares of elements M+1
77 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) DOUBLE PRECISION array, dimension
83 (MAX(1,LWORK))
84 On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
85
86 LWORK (input) INTEGER
87 The dimension of the array WORK. LWORK >= max( 1, MN + max(
88 MN, NRHS ) ). For optimal performance, LWORK >= max( 1, MN +
89 max( MN, NRHS )*NB ). where MN = min(M,N) and NB is the opti‐
90 mum block size. If LWORK = -1, then a workspace query is
91 assumed; the routine only calculates the optimal size of the
92 WORK array, returns this value as the first entry of the WORK
93 array, and no error message related to LWORK is issued by
94 XERBLA.
95
96 INFO (output) INTEGER
97 = 0: successful exit
98 < 0: if INFO = -i, the i-th argument had an illegal value
99 > 0: if INFO = i, the i-th diagonal element of the triangular
100 factor of A is zero, so that A does not have full rank; the
101 least squares solution could not be computed.
102
103
104
105 LAPACK driver routine (version 3.N2o)vember 2008 DGELS(1)