LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sbdt01.f
Go to the documentation of this file.
1*> \brief \b SBDT01
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8* Definition:
9* ===========
10*
11* SUBROUTINE SBDT01( M, N, KD, A, LDA, Q, LDQ, D, E, PT, LDPT, WORK,
12* RESID )
13*
14* .. Scalar Arguments ..
15* INTEGER KD, LDA, LDPT, LDQ, M, N
16* REAL RESID
17* ..
18* .. Array Arguments ..
19* REAL A( LDA, * ), D( * ), E( * ), PT( LDPT, * ),
20* $ Q( LDQ, * ), WORK( * )
21* ..
22*
23*
24*> \par Purpose:
25* =============
26*>
27*> \verbatim
28*>
29*> SBDT01 reconstructs a general matrix A from its bidiagonal form
30*> A = Q * B * P**T
31*> where Q (m by min(m,n)) and P**T (min(m,n) by n) are orthogonal
32*> matrices and B is bidiagonal.
33*>
34*> The test ratio to test the reduction is
35*> RESID = norm(A - Q * B * P**T) / ( n * norm(A) * EPS )
36*> where EPS is the machine precision.
37*> \endverbatim
38*
39* Arguments:
40* ==========
41*
42*> \param[in] M
43*> \verbatim
44*> M is INTEGER
45*> The number of rows of the matrices A and Q.
46*> \endverbatim
47*>
48*> \param[in] N
49*> \verbatim
50*> N is INTEGER
51*> The number of columns of the matrices A and P**T.
52*> \endverbatim
53*>
54*> \param[in] KD
55*> \verbatim
56*> KD is INTEGER
57*> If KD = 0, B is diagonal and the array E is not referenced.
58*> If KD = 1, the reduction was performed by xGEBRD; B is upper
59*> bidiagonal if M >= N, and lower bidiagonal if M < N.
60*> If KD = -1, the reduction was performed by xGBBRD; B is
61*> always upper bidiagonal.
62*> \endverbatim
63*>
64*> \param[in] A
65*> \verbatim
66*> A is REAL array, dimension (LDA,N)
67*> The m by n matrix A.
68*> \endverbatim
69*>
70*> \param[in] LDA
71*> \verbatim
72*> LDA is INTEGER
73*> The leading dimension of the array A. LDA >= max(1,M).
74*> \endverbatim
75*>
76*> \param[in] Q
77*> \verbatim
78*> Q is REAL array, dimension (LDQ,N)
79*> The m by min(m,n) orthogonal matrix Q in the reduction
80*> A = Q * B * P**T.
81*> \endverbatim
82*>
83*> \param[in] LDQ
84*> \verbatim
85*> LDQ is INTEGER
86*> The leading dimension of the array Q. LDQ >= max(1,M).
87*> \endverbatim
88*>
89*> \param[in] D
90*> \verbatim
91*> D is REAL array, dimension (min(M,N))
92*> The diagonal elements of the bidiagonal matrix B.
93*> \endverbatim
94*>
95*> \param[in] E
96*> \verbatim
97*> E is REAL array, dimension (min(M,N)-1)
98*> The superdiagonal elements of the bidiagonal matrix B if
99*> m >= n, or the subdiagonal elements of B if m < n.
100*> \endverbatim
101*>
102*> \param[in] PT
103*> \verbatim
104*> PT is REAL array, dimension (LDPT,N)
105*> The min(m,n) by n orthogonal matrix P**T in the reduction
106*> A = Q * B * P**T.
107*> \endverbatim
108*>
109*> \param[in] LDPT
110*> \verbatim
111*> LDPT is INTEGER
112*> The leading dimension of the array PT.
113*> LDPT >= max(1,min(M,N)).
114*> \endverbatim
115*>
116*> \param[out] WORK
117*> \verbatim
118*> WORK is REAL array, dimension (M+N)
119*> \endverbatim
120*>
121*> \param[out] RESID
122*> \verbatim
123*> RESID is REAL
124*> The test ratio:
125*> norm(A - Q * B * P**T) / ( n * norm(A) * EPS )
126*> \endverbatim
127*
128* Authors:
129* ========
130*
131*> \author Univ. of Tennessee
132*> \author Univ. of California Berkeley
133*> \author Univ. of Colorado Denver
134*> \author NAG Ltd.
135*
136*> \ingroup single_eig
137*
138* =====================================================================
139 SUBROUTINE sbdt01( M, N, KD, A, LDA, Q, LDQ, D, E, PT, LDPT, WORK,
140 $ RESID )
141*
142* -- LAPACK test routine --
143* -- LAPACK is a software package provided by Univ. of Tennessee, --
144* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
145*
146* .. Scalar Arguments ..
147 INTEGER KD, LDA, LDPT, LDQ, M, N
148 REAL RESID
149* ..
150* .. Array Arguments ..
151 REAL A( LDA, * ), D( * ), E( * ), PT( LDPT, * ),
152 $ q( ldq, * ), work( * )
153* ..
154*
155* =====================================================================
156*
157* .. Parameters ..
158 REAL ZERO, ONE
159 parameter( zero = 0.0e+0, one = 1.0e+0 )
160* ..
161* .. Local Scalars ..
162 INTEGER I, J
163 REAL ANORM, EPS
164* ..
165* .. External Functions ..
166 REAL SASUM, SLAMCH, SLANGE
167 EXTERNAL sasum, slamch, slange
168* ..
169* .. External Subroutines ..
170 EXTERNAL scopy, sgemv
171* ..
172* .. Intrinsic Functions ..
173 INTRINSIC max, min, real
174* ..
175* .. Executable Statements ..
176*
177* Quick return if possible
178*
179 IF( m.LE.0 .OR. n.LE.0 ) THEN
180 resid = zero
181 RETURN
182 END IF
183*
184* Compute A - Q * B * P**T one column at a time.
185*
186 resid = zero
187 IF( kd.NE.0 ) THEN
188*
189* B is bidiagonal.
190*
191 IF( kd.NE.0 .AND. m.GE.n ) THEN
192*
193* B is upper bidiagonal and M >= N.
194*
195 DO 20 j = 1, n
196 CALL scopy( m, a( 1, j ), 1, work, 1 )
197 DO 10 i = 1, n - 1
198 work( m+i ) = d( i )*pt( i, j ) + e( i )*pt( i+1, j )
199 10 CONTINUE
200 work( m+n ) = d( n )*pt( n, j )
201 CALL sgemv( 'No transpose', m, n, -one, q, ldq,
202 $ work( m+1 ), 1, one, work, 1 )
203 resid = max( resid, sasum( m, work, 1 ) )
204 20 CONTINUE
205 ELSE IF( kd.LT.0 ) THEN
206*
207* B is upper bidiagonal and M < N.
208*
209 DO 40 j = 1, n
210 CALL scopy( m, a( 1, j ), 1, work, 1 )
211 DO 30 i = 1, m - 1
212 work( m+i ) = d( i )*pt( i, j ) + e( i )*pt( i+1, j )
213 30 CONTINUE
214 work( m+m ) = d( m )*pt( m, j )
215 CALL sgemv( 'No transpose', m, m, -one, q, ldq,
216 $ work( m+1 ), 1, one, work, 1 )
217 resid = max( resid, sasum( m, work, 1 ) )
218 40 CONTINUE
219 ELSE
220*
221* B is lower bidiagonal.
222*
223 DO 60 j = 1, n
224 CALL scopy( m, a( 1, j ), 1, work, 1 )
225 work( m+1 ) = d( 1 )*pt( 1, j )
226 DO 50 i = 2, m
227 work( m+i ) = e( i-1 )*pt( i-1, j ) +
228 $ d( i )*pt( i, j )
229 50 CONTINUE
230 CALL sgemv( 'No transpose', m, m, -one, q, ldq,
231 $ work( m+1 ), 1, one, work, 1 )
232 resid = max( resid, sasum( m, work, 1 ) )
233 60 CONTINUE
234 END IF
235 ELSE
236*
237* B is diagonal.
238*
239 IF( m.GE.n ) THEN
240 DO 80 j = 1, n
241 CALL scopy( m, a( 1, j ), 1, work, 1 )
242 DO 70 i = 1, n
243 work( m+i ) = d( i )*pt( i, j )
244 70 CONTINUE
245 CALL sgemv( 'No transpose', m, n, -one, q, ldq,
246 $ work( m+1 ), 1, one, work, 1 )
247 resid = max( resid, sasum( m, work, 1 ) )
248 80 CONTINUE
249 ELSE
250 DO 100 j = 1, n
251 CALL scopy( m, a( 1, j ), 1, work, 1 )
252 DO 90 i = 1, m
253 work( m+i ) = d( i )*pt( i, j )
254 90 CONTINUE
255 CALL sgemv( 'No transpose', m, m, -one, q, ldq,
256 $ work( m+1 ), 1, one, work, 1 )
257 resid = max( resid, sasum( m, work, 1 ) )
258 100 CONTINUE
259 END IF
260 END IF
261*
262* Compute norm(A - Q * B * P**T) / ( n * norm(A) * EPS )
263*
264 anorm = slange( '1', m, n, a, lda, work )
265 eps = slamch( 'Precision' )
266*
267 IF( anorm.LE.zero ) THEN
268 IF( resid.NE.zero )
269 $ resid = one / eps
270 ELSE
271 IF( anorm.GE.resid ) THEN
272 resid = ( resid / anorm ) / ( real( n )*eps )
273 ELSE
274 IF( anorm.LT.one ) THEN
275 resid = ( min( resid, real( n )*anorm ) / anorm ) /
276 $ ( real( n )*eps )
277 ELSE
278 resid = min( resid / anorm, real( n ) ) /
279 $ ( real( n )*eps )
280 END IF
281 END IF
282 END IF
283*
284 RETURN
285*
286* End of SBDT01
287*
288 END
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
Definition scopy.f:82
subroutine sgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
SGEMV
Definition sgemv.f:158
subroutine sbdt01(m, n, kd, a, lda, q, ldq, d, e, pt, ldpt, work, resid)
SBDT01
Definition sbdt01.f:141