LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sorghr.f
Go to the documentation of this file.
1*> \brief \b SORGHR
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SORGHR + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorghr.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorghr.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorghr.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SORGHR( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER IHI, ILO, INFO, LDA, LWORK, N
23* ..
24* .. Array Arguments ..
25* REAL A( LDA, * ), TAU( * ), WORK( * )
26* ..
27*
28*
29*> \par Purpose:
30* =============
31*>
32*> \verbatim
33*>
34*> SORGHR generates a real orthogonal matrix Q which is defined as the
35*> product of IHI-ILO elementary reflectors of order N, as returned by
36*> SGEHRD:
37*>
38*> Q = H(ilo) H(ilo+1) . . . H(ihi-1).
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] N
45*> \verbatim
46*> N is INTEGER
47*> The order of the matrix Q. N >= 0.
48*> \endverbatim
49*>
50*> \param[in] ILO
51*> \verbatim
52*> ILO is INTEGER
53*> \endverbatim
54*>
55*> \param[in] IHI
56*> \verbatim
57*> IHI is INTEGER
58*>
59*> ILO and IHI must have the same values as in the previous call
60*> of SGEHRD. Q is equal to the unit matrix except in the
61*> submatrix Q(ilo+1:ihi,ilo+1:ihi).
62*> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
63*> \endverbatim
64*>
65*> \param[in,out] A
66*> \verbatim
67*> A is REAL array, dimension (LDA,N)
68*> On entry, the vectors which define the elementary reflectors,
69*> as returned by SGEHRD.
70*> On exit, the N-by-N orthogonal matrix Q.
71*> \endverbatim
72*>
73*> \param[in] LDA
74*> \verbatim
75*> LDA is INTEGER
76*> The leading dimension of the array A. LDA >= max(1,N).
77*> \endverbatim
78*>
79*> \param[in] TAU
80*> \verbatim
81*> TAU is REAL array, dimension (N-1)
82*> TAU(i) must contain the scalar factor of the elementary
83*> reflector H(i), as returned by SGEHRD.
84*> \endverbatim
85*>
86*> \param[out] WORK
87*> \verbatim
88*> WORK is REAL array, dimension (MAX(1,LWORK))
89*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
90*> \endverbatim
91*>
92*> \param[in] LWORK
93*> \verbatim
94*> LWORK is INTEGER
95*> The dimension of the array WORK. LWORK >= IHI-ILO.
96*> For optimum performance LWORK >= (IHI-ILO)*NB, where NB is
97*> the optimal blocksize.
98*>
99*> If LWORK = -1, then a workspace query is assumed; the routine
100*> only calculates the optimal size of the WORK array, returns
101*> this value as the first entry of the WORK array, and no error
102*> message related to LWORK is issued by XERBLA.
103*> \endverbatim
104*>
105*> \param[out] INFO
106*> \verbatim
107*> INFO is INTEGER
108*> = 0: successful exit
109*> < 0: if INFO = -i, the i-th argument had an illegal value
110*> \endverbatim
111*
112* Authors:
113* ========
114*
115*> \author Univ. of Tennessee
116*> \author Univ. of California Berkeley
117*> \author Univ. of Colorado Denver
118*> \author NAG Ltd.
119*
120*> \ingroup unghr
121*
122* =====================================================================
123 SUBROUTINE sorghr( N, ILO, IHI, A, LDA, TAU, WORK, LWORK,
124 $ INFO )
125*
126* -- LAPACK computational routine --
127* -- LAPACK is a software package provided by Univ. of Tennessee, --
128* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
129*
130* .. Scalar Arguments ..
131 INTEGER IHI, ILO, INFO, LDA, LWORK, N
132* ..
133* .. Array Arguments ..
134 REAL A( LDA, * ), TAU( * ), WORK( * )
135* ..
136*
137* =====================================================================
138*
139* .. Parameters ..
140 REAL ZERO, ONE
141 parameter( zero = 0.0e+0, one = 1.0e+0 )
142* ..
143* .. Local Scalars ..
144 LOGICAL LQUERY
145 INTEGER I, IINFO, J, LWKOPT, NB, NH
146* ..
147* .. External Subroutines ..
148 EXTERNAL sorgqr, xerbla
149* ..
150* .. External Functions ..
151 INTEGER ILAENV
152 REAL SROUNDUP_LWORK
153 EXTERNAL ilaenv, sroundup_lwork
154* ..
155* .. Intrinsic Functions ..
156 INTRINSIC max, min
157* ..
158* .. Executable Statements ..
159*
160* Test the input arguments
161*
162 info = 0
163 nh = ihi - ilo
164 lquery = ( lwork.EQ.-1 )
165 IF( n.LT.0 ) THEN
166 info = -1
167 ELSE IF( ilo.LT.1 .OR. ilo.GT.max( 1, n ) ) THEN
168 info = -2
169 ELSE IF( ihi.LT.min( ilo, n ) .OR. ihi.GT.n ) THEN
170 info = -3
171 ELSE IF( lda.LT.max( 1, n ) ) THEN
172 info = -5
173 ELSE IF( lwork.LT.max( 1, nh ) .AND. .NOT.lquery ) THEN
174 info = -8
175 END IF
176*
177 IF( info.EQ.0 ) THEN
178 nb = ilaenv( 1, 'SORGQR', ' ', nh, nh, nh, -1 )
179 lwkopt = max( 1, nh )*nb
180 work( 1 ) = sroundup_lwork(lwkopt)
181 END IF
182*
183 IF( info.NE.0 ) THEN
184 CALL xerbla( 'SORGHR', -info )
185 RETURN
186 ELSE IF( lquery ) THEN
187 RETURN
188 END IF
189*
190* Quick return if possible
191*
192 IF( n.EQ.0 ) THEN
193 work( 1 ) = 1
194 RETURN
195 END IF
196*
197* Shift the vectors which define the elementary reflectors one
198* column to the right, and set the first ilo and the last n-ihi
199* rows and columns to those of the unit matrix
200*
201 DO 40 j = ihi, ilo + 1, -1
202 DO 10 i = 1, j - 1
203 a( i, j ) = zero
204 10 CONTINUE
205 DO 20 i = j + 1, ihi
206 a( i, j ) = a( i, j-1 )
207 20 CONTINUE
208 DO 30 i = ihi + 1, n
209 a( i, j ) = zero
210 30 CONTINUE
211 40 CONTINUE
212 DO 60 j = 1, ilo
213 DO 50 i = 1, n
214 a( i, j ) = zero
215 50 CONTINUE
216 a( j, j ) = one
217 60 CONTINUE
218 DO 80 j = ihi + 1, n
219 DO 70 i = 1, n
220 a( i, j ) = zero
221 70 CONTINUE
222 a( j, j ) = one
223 80 CONTINUE
224*
225 IF( nh.GT.0 ) THEN
226*
227* Generate Q(ilo+1:ihi,ilo+1:ihi)
228*
229 CALL sorgqr( nh, nh, nh, a( ilo+1, ilo+1 ), lda, tau( ilo ),
230 $ work, lwork, iinfo )
231 END IF
232 work( 1 ) = sroundup_lwork(lwkopt)
233 RETURN
234*
235* End of SORGHR
236*
237 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sorghr(n, ilo, ihi, a, lda, tau, work, lwork, info)
SORGHR
Definition sorghr.f:125
subroutine sorgqr(m, n, k, a, lda, tau, work, lwork, info)
SORGQR
Definition sorgqr.f:126