LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dbdt04 ( character  UPLO,
integer  N,
double precision, dimension( * )  D,
double precision, dimension( * )  E,
double precision, dimension( * )  S,
integer  NS,
double precision, dimension( ldu, * )  U,
integer  LDU,
double precision, dimension( ldvt, * )  VT,
integer  LDVT,
double precision, dimension( * )  WORK,
double precision  RESID 
)
Purpose:

DBDT04 reconstructs a bidiagonal matrix B from its (partial) SVD: S = U' * B * V where U and V are orthogonal matrices and S is diagonal.

The test ratio to test the singular value decomposition is RESID = norm( S - U' * B * V ) / ( n * norm(B) * EPS ) where VT = V' and EPS is the machine precision.

Parameters
[in]UPLO
          UPLO is CHARACTER*1
          Specifies whether the matrix B is upper or lower bidiagonal.
          = 'U':  Upper bidiagonal
          = 'L':  Lower bidiagonal
[in]N
          N is INTEGER
          The order of the matrix B.
[in]D
          D is DOUBLE PRECISION array, dimension (N)
          The n diagonal elements of the bidiagonal matrix B.
[in]E
          E is DOUBLE PRECISION array, dimension (N-1)
          The (n-1) superdiagonal elements of the bidiagonal matrix B
          if UPLO = 'U', or the (n-1) subdiagonal elements of B if
          UPLO = 'L'.
[in]S
          S is DOUBLE PRECISION array, dimension (NS)
          The singular values from the (partial) SVD of B, sorted in 
          decreasing order.
[in]NS
          NS is INTEGER
          The number of singular values/vectors from the (partial) 
          SVD of B.
[in]U
          U is DOUBLE PRECISION array, dimension (LDU,NS)
          The n by ns orthogonal matrix U in S = U' * B * V.
[in]LDU
          LDU is INTEGER
          The leading dimension of the array U.  LDU >= max(1,N)
[in]VT
          VT is DOUBLE PRECISION array, dimension (LDVT,N)
          The n by ns orthogonal matrix V in S = U' * B * V.
[in]LDVT
          LDVT is INTEGER
          The leading dimension of the array VT.
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (2*N)
[out]RESID
          RESID is DOUBLE PRECISION
          The test ratio:  norm(S - U' * B * V) / ( n * norm(B) * EPS )
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011

Definition at line 132 of file dbdt04.f.

132 *
133 * -- LAPACK test routine (version 3.4.0) --
134 * -- LAPACK is a software package provided by Univ. of Tennessee, --
135 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
136 * November 2011
137 *
138 * .. Scalar Arguments ..
139  CHARACTER uplo
140  INTEGER ldu, ldvt, n, ns
141  DOUBLE PRECISION resid
142 * ..
143 * .. Array Arguments ..
144  DOUBLE PRECISION d( * ), e( * ), s( * ), u( ldu, * ),
145  $ vt( ldvt, * ), work( * )
146 * ..
147 *
148 * ======================================================================
149 *
150 * .. Parameters ..
151  DOUBLE PRECISION zero, one
152  parameter ( zero = 0.0d+0, one = 1.0d+0 )
153 * ..
154 * .. Local Scalars ..
155  INTEGER i, j, k
156  DOUBLE PRECISION bnorm, eps
157 * ..
158 * .. External Functions ..
159  LOGICAL lsame
160  INTEGER idamax
161  DOUBLE PRECISION dasum, dlamch
162  EXTERNAL lsame, idamax, dasum, dlamch
163 * ..
164 * .. External Subroutines ..
165  EXTERNAL dgemm
166 * ..
167 * .. Intrinsic Functions ..
168  INTRINSIC abs, dble, max, min
169 * ..
170 * .. Executable Statements ..
171 *
172 * Quick return if possible.
173 *
174  resid = zero
175  IF( n.LE.0 .OR. ns.LE.0 )
176  $ RETURN
177 *
178  eps = dlamch( 'Precision' )
179 *
180 * Compute S - U' * B * V.
181 *
182  bnorm = zero
183 *
184  IF( lsame( uplo, 'U' ) ) THEN
185 *
186 * B is upper bidiagonal.
187 *
188  k = 0
189  DO 20 i = 1, ns
190  DO 10 j = 1, n-1
191  k = k + 1
192  work( k ) = d( j )*vt( i, j ) + e( j )*vt( i, j+1 )
193  10 CONTINUE
194  k = k + 1
195  work( k ) = d( n )*vt( i, n )
196  20 CONTINUE
197  bnorm = abs( d( 1 ) )
198  DO 30 i = 2, n
199  bnorm = max( bnorm, abs( d( i ) )+abs( e( i-1 ) ) )
200  30 CONTINUE
201  ELSE
202 *
203 * B is lower bidiagonal.
204 *
205  k = 0
206  DO 50 i = 1, ns
207  k = k + 1
208  work( k ) = d( 1 )*vt( i, 1 )
209  DO 40 j = 1, n-1
210  k = k + 1
211  work( k ) = e( j )*vt( i, j ) + d( j+1 )*vt( i, j+1 )
212  40 CONTINUE
213  50 CONTINUE
214  bnorm = abs( d( n ) )
215  DO 60 i = 1, n-1
216  bnorm = max( bnorm, abs( d( i ) )+abs( e( i ) ) )
217  60 CONTINUE
218  END IF
219 *
220  CALL dgemm( 'T', 'N', ns, ns, n, -one, u, ldu, work( 1 ),
221  $ n, zero, work( 1+n*ns ), ns )
222 *
223 * norm(S - U' * B * V)
224 *
225  k = n*ns
226  DO 70 i = 1, ns
227  work( k+i ) = work( k+i ) + s( i )
228  resid = max( resid, dasum( ns, work( k+1 ), 1 ) )
229  k = k + ns
230  70 CONTINUE
231 *
232  IF( bnorm.LE.zero ) THEN
233  IF( resid.NE.zero )
234  $ resid = one / eps
235  ELSE
236  IF( bnorm.GE.resid ) THEN
237  resid = ( resid / bnorm ) / ( dble( n )*eps )
238  ELSE
239  IF( bnorm.LT.one ) THEN
240  resid = ( min( resid, dble( n )*bnorm ) / bnorm ) /
241  $ ( dble( n )*eps )
242  ELSE
243  resid = min( resid / bnorm, dble( n ) ) /
244  $ ( dble( n )*eps )
245  END IF
246  END IF
247  END IF
248 *
249  RETURN
250 *
251 * End of DBDT04
252 *
integer function idamax(N, DX, INCX)
IDAMAX
Definition: idamax.f:53
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:189
double precision function dasum(N, DX, INCX)
DASUM
Definition: dasum.f:53
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55

Here is the call graph for this function:

Here is the caller graph for this function: