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

SBDT04 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 REAL array, dimension (N)
          The n diagonal elements of the bidiagonal matrix B.
[in]E
          E is REAL 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 REAL 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 REAL 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 REAL 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 REAL array, dimension (2*N)
[out]RESID
          RESID is REAL
          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 sbdt04.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  REAL resid
142 * ..
143 * .. Array Arguments ..
144  REAL d( * ), e( * ), s( * ), u( ldu, * ),
145  $ vt( ldvt, * ), work( * )
146 * ..
147 *
148 * ======================================================================
149 *
150 * .. Parameters ..
151  REAL zero, one
152  parameter ( zero = 0.0e+0, one = 1.0e+0 )
153 * ..
154 * .. Local Scalars ..
155  INTEGER i, j, k
156  REAL bnorm, eps
157 * ..
158 * .. External Functions ..
159  LOGICAL lsame
160  INTEGER isamax
161  REAL sasum, slamch
162  EXTERNAL lsame, isamax, sasum, slamch
163 * ..
164 * .. External Subroutines ..
165  EXTERNAL sgemm
166 * ..
167 * .. Intrinsic Functions ..
168  INTRINSIC abs, REAL, 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 = slamch( '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 sgemm( '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, sasum( 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 ) / ( REAL( n )*eps )
238  ELSE
239  IF( bnorm.LT.one ) THEN
240  resid = ( min( resid, REAL( n )*bnorm ) / bnorm ) /
241  $ ( REAL( n )*eps )
242  ELSE
243  resid = min( resid / bnorm, REAL( N ) ) /
244  $ ( REAL( n )*eps )
245  END IF
246  END IF
247  END IF
248 *
249  RETURN
250 *
251 * End of SBDT04
252 *
integer function isamax(N, SX, INCX)
ISAMAX
Definition: isamax.f:53
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:189
real function sasum(N, SX, INCX)
SASUM
Definition: sasum.f:54
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
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: