1 | *> \brief \b SGEQR2 |
---|
2 | * |
---|
3 | * =========== DOCUMENTATION =========== |
---|
4 | * |
---|
5 | * Online html documentation available at |
---|
6 | * http://www.netlib.org/lapack/explore-html/ |
---|
7 | * |
---|
8 | *> \htmlonly |
---|
9 | *> Download SGEQR2 + dependencies |
---|
10 | *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeqr2.f"> |
---|
11 | *> [TGZ]</a> |
---|
12 | *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeqr2.f"> |
---|
13 | *> [ZIP]</a> |
---|
14 | *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeqr2.f"> |
---|
15 | *> [TXT]</a> |
---|
16 | *> \endhtmlonly |
---|
17 | * |
---|
18 | * Definition: |
---|
19 | * =========== |
---|
20 | * |
---|
21 | * SUBROUTINE SGEQR2( M, N, A, LDA, TAU, WORK, INFO ) |
---|
22 | * |
---|
23 | * .. Scalar Arguments .. |
---|
24 | * INTEGER INFO, LDA, M, N |
---|
25 | * .. |
---|
26 | * .. Array Arguments .. |
---|
27 | * REAL A( LDA, * ), TAU( * ), WORK( * ) |
---|
28 | * .. |
---|
29 | * |
---|
30 | * |
---|
31 | *> \par Purpose: |
---|
32 | * ============= |
---|
33 | *> |
---|
34 | *> \verbatim |
---|
35 | *> |
---|
36 | *> SGEQR2 computes a QR factorization of a real m by n matrix A: |
---|
37 | *> A = Q * R. |
---|
38 | *> \endverbatim |
---|
39 | * |
---|
40 | * Arguments: |
---|
41 | * ========== |
---|
42 | * |
---|
43 | *> \param[in] M |
---|
44 | *> \verbatim |
---|
45 | *> M is INTEGER |
---|
46 | *> The number of rows of the matrix A. M >= 0. |
---|
47 | *> \endverbatim |
---|
48 | *> |
---|
49 | *> \param[in] N |
---|
50 | *> \verbatim |
---|
51 | *> N is INTEGER |
---|
52 | *> The number of columns of the matrix A. N >= 0. |
---|
53 | *> \endverbatim |
---|
54 | *> |
---|
55 | *> \param[in,out] A |
---|
56 | *> \verbatim |
---|
57 | *> A is REAL array, dimension (LDA,N) |
---|
58 | *> On entry, the m by n matrix A. |
---|
59 | *> On exit, the elements on and above the diagonal of the array |
---|
60 | *> contain the min(m,n) by n upper trapezoidal matrix R (R is |
---|
61 | *> upper triangular if m >= n); the elements below the diagonal, |
---|
62 | *> with the array TAU, represent the orthogonal matrix Q as a |
---|
63 | *> product of elementary reflectors (see Further Details). |
---|
64 | *> \endverbatim |
---|
65 | *> |
---|
66 | *> \param[in] LDA |
---|
67 | *> \verbatim |
---|
68 | *> LDA is INTEGER |
---|
69 | *> The leading dimension of the array A. LDA >= max(1,M). |
---|
70 | *> \endverbatim |
---|
71 | *> |
---|
72 | *> \param[out] TAU |
---|
73 | *> \verbatim |
---|
74 | *> TAU is REAL array, dimension (min(M,N)) |
---|
75 | *> The scalar factors of the elementary reflectors (see Further |
---|
76 | *> Details). |
---|
77 | *> \endverbatim |
---|
78 | *> |
---|
79 | *> \param[out] WORK |
---|
80 | *> \verbatim |
---|
81 | *> WORK is REAL array, dimension (N) |
---|
82 | *> \endverbatim |
---|
83 | *> |
---|
84 | *> \param[out] INFO |
---|
85 | *> \verbatim |
---|
86 | *> INFO is INTEGER |
---|
87 | *> = 0: successful exit |
---|
88 | *> < 0: if INFO = -i, the i-th argument had an illegal value |
---|
89 | *> \endverbatim |
---|
90 | * |
---|
91 | * Authors: |
---|
92 | * ======== |
---|
93 | * |
---|
94 | *> \author Univ. of Tennessee |
---|
95 | *> \author Univ. of California Berkeley |
---|
96 | *> \author Univ. of Colorado Denver |
---|
97 | *> \author NAG Ltd. |
---|
98 | * |
---|
99 | *> \date November 2011 |
---|
100 | * |
---|
101 | *> \ingroup realGEcomputational |
---|
102 | * |
---|
103 | *> \par Further Details: |
---|
104 | * ===================== |
---|
105 | *> |
---|
106 | *> \verbatim |
---|
107 | *> |
---|
108 | *> The matrix Q is represented as a product of elementary reflectors |
---|
109 | *> |
---|
110 | *> Q = H(1) H(2) . . . H(k), where k = min(m,n). |
---|
111 | *> |
---|
112 | *> Each H(i) has the form |
---|
113 | *> |
---|
114 | *> H(i) = I - tau * v * v**T |
---|
115 | *> |
---|
116 | *> where tau is a real scalar, and v is a real vector with |
---|
117 | *> v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), |
---|
118 | *> and tau in TAU(i). |
---|
119 | *> \endverbatim |
---|
120 | *> |
---|
121 | * ===================================================================== |
---|
122 | SUBROUTINE SGEQR2( M, N, A, LDA, TAU, WORK, INFO ) |
---|
123 | * |
---|
124 | * -- LAPACK computational routine (version 3.4.0) -- |
---|
125 | * -- LAPACK is a software package provided by Univ. of Tennessee, -- |
---|
126 | * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
---|
127 | * November 2011 |
---|
128 | * |
---|
129 | * .. Scalar Arguments .. |
---|
130 | INTEGER INFO, LDA, M, N |
---|
131 | * .. |
---|
132 | * .. Array Arguments .. |
---|
133 | REAL A( LDA, * ), TAU( * ), WORK( * ) |
---|
134 | * .. |
---|
135 | * |
---|
136 | * ===================================================================== |
---|
137 | * |
---|
138 | * .. Parameters .. |
---|
139 | REAL ONE |
---|
140 | PARAMETER ( ONE = 1.0E+0 ) |
---|
141 | * .. |
---|
142 | * .. Local Scalars .. |
---|
143 | INTEGER I, K |
---|
144 | REAL AII |
---|
145 | * .. |
---|
146 | * .. External Subroutines .. |
---|
147 | EXTERNAL SLARF, SLARFG, XERBLA |
---|
148 | * .. |
---|
149 | * .. Intrinsic Functions .. |
---|
150 | INTRINSIC MAX, MIN |
---|
151 | * .. |
---|
152 | * .. Executable Statements .. |
---|
153 | * |
---|
154 | * Test the input arguments |
---|
155 | * |
---|
156 | INFO = 0 |
---|
157 | IF( M.LT.0 ) THEN |
---|
158 | INFO = -1 |
---|
159 | ELSE IF( N.LT.0 ) THEN |
---|
160 | INFO = -2 |
---|
161 | ELSE IF( LDA.LT.MAX( 1, M ) ) THEN |
---|
162 | INFO = -4 |
---|
163 | END IF |
---|
164 | IF( INFO.NE.0 ) THEN |
---|
165 | CALL XERBLA( 'SGEQR2', -INFO ) |
---|
166 | RETURN |
---|
167 | END IF |
---|
168 | * |
---|
169 | K = MIN( M, N ) |
---|
170 | * |
---|
171 | DO 10 I = 1, K |
---|
172 | * |
---|
173 | * Generate elementary reflector H(i) to annihilate A(i+1:m,i) |
---|
174 | * |
---|
175 | CALL SLARFG( M-I+1, A( I, I ), A( MIN( I+1, M ), I ), 1, |
---|
176 | $ TAU( I ) ) |
---|
177 | IF( I.LT.N ) THEN |
---|
178 | * |
---|
179 | * Apply H(i) to A(i:m,i+1:n) from the left |
---|
180 | * |
---|
181 | AII = A( I, I ) |
---|
182 | A( I, I ) = ONE |
---|
183 | CALL SLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAU( I ), |
---|
184 | $ A( I, I+1 ), LDA, WORK ) |
---|
185 | A( I, I ) = AII |
---|
186 | END IF |
---|
187 | 10 CONTINUE |
---|
188 | RETURN |
---|
189 | * |
---|
190 | * End of SGEQR2 |
---|
191 | * |
---|
192 | END |
---|