LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ sqrt12()

real function sqrt12 ( integer  M,
integer  N,
real, dimension( lda, * )  A,
integer  LDA,
real, dimension( * )  S,
real, dimension( lwork )  WORK,
integer  LWORK 
)

SQRT12

Purpose:
 SQRT12 computes the singular values `svlues' of the upper trapezoid
 of A(1:M,1:N) and returns the ratio

      || s - svlues||/(||svlues||*eps*max(M,N))
Parameters
[in]M
          M is INTEGER
          The number of rows of the matrix A.
[in]N
          N is INTEGER
          The number of columns of the matrix A.
[in]A
          A is REAL array, dimension (LDA,N)
          The M-by-N matrix A. Only the upper trapezoid is referenced.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.
[in]S
          S is REAL array, dimension (min(M,N))
          The singular values of the matrix A.
[out]WORK
          WORK is REAL array, dimension (LWORK)
[in]LWORK
          LWORK is INTEGER
          The length of the array WORK. LWORK >= max(M*N + 4*min(M,N) +
          max(M,N), M*N+2*MIN( M, N )+4*N).
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 88 of file sqrt12.f.

89 *
90 * -- LAPACK test routine --
91 * -- LAPACK is a software package provided by Univ. of Tennessee, --
92 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
93 *
94 * .. Scalar Arguments ..
95  INTEGER LDA, LWORK, M, N
96 * ..
97 * .. Array Arguments ..
98  REAL A( LDA, * ), S( * ), WORK( LWORK )
99 * ..
100 *
101 * =====================================================================
102 *
103 * .. Parameters ..
104  REAL ZERO, ONE
105  parameter( zero = 0.0e0, one = 1.0e0 )
106 * ..
107 * .. Local Scalars ..
108  INTEGER I, INFO, ISCL, J, MN
109  REAL ANRM, BIGNUM, NRMSVL, SMLNUM
110 * ..
111 * .. External Functions ..
112  REAL SASUM, SLAMCH, SLANGE, SNRM2
113  EXTERNAL sasum, slamch, slange, snrm2
114 * ..
115 * .. External Subroutines ..
116  EXTERNAL saxpy, sbdsqr, sgebd2, slabad, slascl, slaset,
117  $ xerbla
118 * ..
119 * .. Intrinsic Functions ..
120  INTRINSIC max, min, real
121 * ..
122 * .. Local Arrays ..
123  REAL DUMMY( 1 )
124 * ..
125 * .. Executable Statements ..
126 *
127  sqrt12 = zero
128 *
129 * Test that enough workspace is supplied
130 *
131  IF( lwork.LT.max( m*n+4*min( m, n )+max( m, n ),
132  $ m*n+2*min( m, n )+4*n) ) THEN
133  CALL xerbla( 'SQRT12', 7 )
134  RETURN
135  END IF
136 *
137 * Quick return if possible
138 *
139  mn = min( m, n )
140  IF( mn.LE.zero )
141  $ RETURN
142 *
143  nrmsvl = snrm2( mn, s, 1 )
144 *
145 * Copy upper triangle of A into work
146 *
147  CALL slaset( 'Full', m, n, zero, zero, work, m )
148  DO 20 j = 1, n
149  DO 10 i = 1, min( j, m )
150  work( ( j-1 )*m+i ) = a( i, j )
151  10 CONTINUE
152  20 CONTINUE
153 *
154 * Get machine parameters
155 *
156  smlnum = slamch( 'S' ) / slamch( 'P' )
157  bignum = one / smlnum
158  CALL slabad( smlnum, bignum )
159 *
160 * Scale work if max entry outside range [SMLNUM,BIGNUM]
161 *
162  anrm = slange( 'M', m, n, work, m, dummy )
163  iscl = 0
164  IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
165 *
166 * Scale matrix norm up to SMLNUM
167 *
168  CALL slascl( 'G', 0, 0, anrm, smlnum, m, n, work, m, info )
169  iscl = 1
170  ELSE IF( anrm.GT.bignum ) THEN
171 *
172 * Scale matrix norm down to BIGNUM
173 *
174  CALL slascl( 'G', 0, 0, anrm, bignum, m, n, work, m, info )
175  iscl = 1
176  END IF
177 *
178  IF( anrm.NE.zero ) THEN
179 *
180 * Compute SVD of work
181 *
182  CALL sgebd2( m, n, work, m, work( m*n+1 ), work( m*n+mn+1 ),
183  $ work( m*n+2*mn+1 ), work( m*n+3*mn+1 ),
184  $ work( m*n+4*mn+1 ), info )
185  CALL sbdsqr( 'Upper', mn, 0, 0, 0, work( m*n+1 ),
186  $ work( m*n+mn+1 ), dummy, mn, dummy, 1, dummy, mn,
187  $ work( m*n+2*mn+1 ), info )
188 *
189  IF( iscl.EQ.1 ) THEN
190  IF( anrm.GT.bignum ) THEN
191  CALL slascl( 'G', 0, 0, bignum, anrm, mn, 1,
192  $ work( m*n+1 ), mn, info )
193  END IF
194  IF( anrm.LT.smlnum ) THEN
195  CALL slascl( 'G', 0, 0, smlnum, anrm, mn, 1,
196  $ work( m*n+1 ), mn, info )
197  END IF
198  END IF
199 *
200  ELSE
201 *
202  DO 30 i = 1, mn
203  work( m*n+i ) = zero
204  30 CONTINUE
205  END IF
206 *
207 * Compare s and singular values of work
208 *
209  CALL saxpy( mn, -one, s, 1, work( m*n+1 ), 1 )
210  sqrt12 = sasum( mn, work( m*n+1 ), 1 ) /
211  $ ( slamch( 'Epsilon' )*real( max( m, n ) ) )
212  IF( nrmsvl.NE.zero )
213  $ sqrt12 = sqrt12 / nrmsvl
214 *
215  RETURN
216 *
217 * End of SQRT12
218 *
subroutine slabad(SMALL, LARGE)
SLABAD
Definition: slabad.f:74
subroutine slascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: slascl.f:143
subroutine slaset(UPLO, M, N, ALPHA, BETA, A, LDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: slaset.f:110
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
subroutine sbdsqr(UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U, LDU, C, LDC, WORK, INFO)
SBDSQR
Definition: sbdsqr.f:240
real function slange(NORM, M, N, A, LDA, WORK)
SLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: slange.f:114
subroutine sgebd2(M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO)
SGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm.
Definition: sgebd2.f:189
real(wp) function snrm2(n, x, incx)
SNRM2
Definition: snrm2.f90:89
subroutine saxpy(N, SA, SX, INCX, SY, INCY)
SAXPY
Definition: saxpy.f:89
real function sasum(N, SX, INCX)
SASUM
Definition: sasum.f:72
real function sqrt12(M, N, A, LDA, S, WORK, LWORK)
SQRT12
Definition: sqrt12.f:89
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function: