LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dqrt12.f
Go to the documentation of this file.
1*> \brief \b DQRT12
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8* Definition:
9* ===========
10*
11* DOUBLE PRECISION FUNCTION DQRT12( M, N, A, LDA, S, WORK, LWORK )
12*
13* .. Scalar Arguments ..
14* INTEGER LDA, LWORK, M, N
15* ..
16* .. Array Arguments ..
17* DOUBLE PRECISION A( LDA, * ), S( * ), WORK( LWORK )
18* ..
19*
20*
21*> \par Purpose:
22* =============
23*>
24*> \verbatim
25*>
26*> DQRT12 computes the singular values `svlues' of the upper trapezoid
27*> of A(1:M,1:N) and returns the ratio
28*>
29*> || svlues - s ||/(||s||*eps*max(M,N))
30*> \endverbatim
31*
32* Arguments:
33* ==========
34*
35*> \param[in] M
36*> \verbatim
37*> M is INTEGER
38*> The number of rows of the matrix A.
39*> \endverbatim
40*>
41*> \param[in] N
42*> \verbatim
43*> N is INTEGER
44*> The number of columns of the matrix A.
45*> \endverbatim
46*>
47*> \param[in] A
48*> \verbatim
49*> A is DOUBLE PRECISION array, dimension (LDA,N)
50*> The M-by-N matrix A. Only the upper trapezoid is referenced.
51*> \endverbatim
52*>
53*> \param[in] LDA
54*> \verbatim
55*> LDA is INTEGER
56*> The leading dimension of the array A.
57*> \endverbatim
58*>
59*> \param[in] S
60*> \verbatim
61*> S is DOUBLE PRECISION array, dimension (min(M,N))
62*> The singular values of the matrix A.
63*> \endverbatim
64*>
65*> \param[out] WORK
66*> \verbatim
67*> WORK is DOUBLE PRECISION array, dimension (LWORK)
68*> \endverbatim
69*>
70*> \param[in] LWORK
71*> \verbatim
72*> LWORK is INTEGER
73*> The length of the array WORK. LWORK >= max(M*N + 4*min(M,N) +
74*> max(M,N), M*N+2*MIN( M, N )+4*N).
75*> \endverbatim
76*
77* Authors:
78* ========
79*
80*> \author Univ. of Tennessee
81*> \author Univ. of California Berkeley
82*> \author Univ. of Colorado Denver
83*> \author NAG Ltd.
84*
85*> \ingroup double_lin
86*
87* =====================================================================
88 DOUBLE PRECISION FUNCTION dqrt12( M, N, A, LDA, S, WORK, LWORK )
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 DOUBLE PRECISION a( lda, * ), s( * ), work( lwork )
99* ..
100*
101* =====================================================================
102*
103* .. Parameters ..
104 DOUBLE PRECISION zero, one
105 parameter( zero = 0.0d0, one = 1.0d0 )
106* ..
107* .. Local Scalars ..
108 INTEGER i, info, iscl, j, mn
109 DOUBLE PRECISION anrm, bignum, nrmsvl, smlnum
110* ..
111* .. External Functions ..
112 DOUBLE PRECISION dasum, dlamch, dlange, dnrm2
113 EXTERNAL dasum, dlamch, dlange, dnrm2
114* ..
115* .. External Subroutines ..
116 EXTERNAL daxpy, dbdsqr, dgebd2, dlascl, dlaset, xerbla
117* ..
118* .. Intrinsic Functions ..
119 INTRINSIC dble, max, min
120* ..
121* .. Local Arrays ..
122 DOUBLE PRECISION dummy( 1 )
123* ..
124* .. Executable Statements ..
125*
126 dqrt12 = zero
127*
128* Test that enough workspace is supplied
129*
130 IF( lwork.LT.max( m*n+4*min( m, n )+max( m, n ),
131 $ m*n+2*min( m, n )+4*n) ) THEN
132 CALL xerbla( 'DQRT12', 7 )
133 RETURN
134 END IF
135*
136* Quick return if possible
137*
138 mn = min( m, n )
139 IF( mn.LE.zero )
140 $ RETURN
141*
142 nrmsvl = dnrm2( mn, s, 1 )
143*
144* Copy upper triangle of A into work
145*
146 CALL dlaset( 'Full', m, n, zero, zero, work, m )
147 DO j = 1, n
148 DO i = 1, min( j, m )
149 work( ( j-1 )*m+i ) = a( i, j )
150 END DO
151 END DO
152*
153* Get machine parameters
154*
155 smlnum = dlamch( 'S' ) / dlamch( 'P' )
156 bignum = one / smlnum
157*
158* Scale work if max entry outside range [SMLNUM,BIGNUM]
159*
160 anrm = dlange( 'M', m, n, work, m, dummy )
161 iscl = 0
162 IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
163*
164* Scale matrix norm up to SMLNUM
165*
166 CALL dlascl( 'G', 0, 0, anrm, smlnum, m, n, work, m, info )
167 iscl = 1
168 ELSE IF( anrm.GT.bignum ) THEN
169*
170* Scale matrix norm down to BIGNUM
171*
172 CALL dlascl( 'G', 0, 0, anrm, bignum, m, n, work, m, info )
173 iscl = 1
174 END IF
175*
176 IF( anrm.NE.zero ) THEN
177*
178* Compute SVD of work
179*
180 CALL dgebd2( m, n, work, m, work( m*n+1 ), work( m*n+mn+1 ),
181 $ work( m*n+2*mn+1 ), work( m*n+3*mn+1 ),
182 $ work( m*n+4*mn+1 ), info )
183 CALL dbdsqr( 'Upper', mn, 0, 0, 0, work( m*n+1 ),
184 $ work( m*n+mn+1 ), dummy, mn, dummy, 1, dummy, mn,
185 $ work( m*n+2*mn+1 ), info )
186*
187 IF( iscl.EQ.1 ) THEN
188 IF( anrm.GT.bignum ) THEN
189 CALL dlascl( 'G', 0, 0, bignum, anrm, mn, 1,
190 $ work( m*n+1 ), mn, info )
191 END IF
192 IF( anrm.LT.smlnum ) THEN
193 CALL dlascl( 'G', 0, 0, smlnum, anrm, mn, 1,
194 $ work( m*n+1 ), mn, info )
195 END IF
196 END IF
197*
198 ELSE
199*
200 DO i = 1, mn
201 work( m*n+i ) = zero
202 END DO
203 END IF
204*
205* Compare s and singular values of work
206*
207 CALL daxpy( mn, -one, s, 1, work( m*n+1 ), 1 )
208*
209 dqrt12 = dasum( mn, work( m*n+1 ), 1 ) /
210 $ ( dlamch('Epsilon') * dble( max( m, n ) ) )
211*
212 IF( nrmsvl.NE.zero )
213 $ dqrt12 = dqrt12 / nrmsvl
214*
215 RETURN
216*
217* End of DQRT12
218*
219 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
double precision function dqrt12(m, n, a, lda, s, work, lwork)
DQRT12
Definition dqrt12.f:89
double precision function dasum(n, dx, incx)
DASUM
Definition dasum.f:71
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
subroutine dbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info)
DBDSQR
Definition dbdsqr.f:241
subroutine dgebd2(m, n, a, lda, d, e, tauq, taup, work, info)
DGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm.
Definition dgebd2.f:189
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
double precision function dlange(norm, m, n, a, lda, work)
DLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition dlange.f:114
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition dlascl.f:143
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition dlaset.f:110
real(wp) function dnrm2(n, x, incx)
DNRM2
Definition dnrm2.f90:89