LAPACK  3.8.0
LAPACK: Linear Algebra PACKage
zqrt12.f
Go to the documentation of this file.
1 *> \brief \b ZQRT12
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 ZQRT12( M, N, A, LDA, S, WORK, LWORK,
12 * RWORK )
13 *
14 * .. Scalar Arguments ..
15 * INTEGER LDA, LWORK, M, N
16 * ..
17 * .. Array Arguments ..
18 * DOUBLE PRECISION RWORK( * ), S( * )
19 * COMPLEX*16 A( LDA, * ), WORK( LWORK )
20 * ..
21 *
22 *
23 *> \par Purpose:
24 * =============
25 *>
26 *> \verbatim
27 *>
28 *> ZQRT12 computes the singular values `svlues' of the upper trapezoid
29 *> of A(1:M,1:N) and returns the ratio
30 *>
31 *> || s - svlues||/(||svlues||*eps*max(M,N))
32 *> \endverbatim
33 *
34 * Arguments:
35 * ==========
36 *
37 *> \param[in] M
38 *> \verbatim
39 *> M is INTEGER
40 *> The number of rows of the matrix A.
41 *> \endverbatim
42 *>
43 *> \param[in] N
44 *> \verbatim
45 *> N is INTEGER
46 *> The number of columns of the matrix A.
47 *> \endverbatim
48 *>
49 *> \param[in] A
50 *> \verbatim
51 *> A is COMPLEX*16 array, dimension (LDA,N)
52 *> The M-by-N matrix A. Only the upper trapezoid is referenced.
53 *> \endverbatim
54 *>
55 *> \param[in] LDA
56 *> \verbatim
57 *> LDA is INTEGER
58 *> The leading dimension of the array A.
59 *> \endverbatim
60 *>
61 *> \param[in] S
62 *> \verbatim
63 *> S is DOUBLE PRECISION array, dimension (min(M,N))
64 *> The singular values of the matrix A.
65 *> \endverbatim
66 *>
67 *> \param[out] WORK
68 *> \verbatim
69 *> WORK is COMPLEX*16 array, dimension (LWORK)
70 *> \endverbatim
71 *>
72 *> \param[in] LWORK
73 *> \verbatim
74 *> LWORK is INTEGER
75 *> The length of the array WORK. LWORK >= M*N + 2*min(M,N) +
76 *> max(M,N).
77 *> \endverbatim
78 *>
79 *> \param[out] RWORK
80 *> \verbatim
81 *> RWORK is DOUBLE PRECISION array, dimension (2*min(M,N))
82 *> \endverbatim
83 *
84 * Authors:
85 * ========
86 *
87 *> \author Univ. of Tennessee
88 *> \author Univ. of California Berkeley
89 *> \author Univ. of Colorado Denver
90 *> \author NAG Ltd.
91 *
92 *> \date December 2016
93 *
94 *> \ingroup complex16_lin
95 *
96 * =====================================================================
97  DOUBLE PRECISION FUNCTION zqrt12( M, N, A, LDA, S, WORK, LWORK,
98  $ RWORK )
99 *
100 * -- LAPACK test routine (version 3.7.0) --
101 * -- LAPACK is a software package provided by Univ. of Tennessee, --
102 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
103 * December 2016
104 *
105 * .. Scalar Arguments ..
106  INTEGER LDA, LWORK, M, N
107 * ..
108 * .. Array Arguments ..
109  DOUBLE PRECISION RWORK( * ), S( * )
110  COMPLEX*16 A( lda, * ), WORK( lwork )
111 * ..
112 *
113 * =====================================================================
114 *
115 * .. Parameters ..
116  DOUBLE PRECISION ZERO, ONE
117  parameter( zero = 0.0d0, one = 1.0d0 )
118 * ..
119 * .. Local Scalars ..
120  INTEGER I, INFO, ISCL, J, MN
121  DOUBLE PRECISION ANRM, BIGNUM, NRMSVL, SMLNUM
122 * ..
123 * .. Local Arrays ..
124  DOUBLE PRECISION DUMMY( 1 )
125 * ..
126 * .. External Functions ..
127  DOUBLE PRECISION DASUM, DLAMCH, DNRM2, ZLANGE
128  EXTERNAL dasum, dlamch, dnrm2, zlange
129 * ..
130 * .. External Subroutines ..
131  EXTERNAL daxpy, dbdsqr, dlabad, dlascl, xerbla, zgebd2,
132  $ zlascl, zlaset
133 * ..
134 * .. Intrinsic Functions ..
135  INTRINSIC dble, dcmplx, max, min
136 * ..
137 * .. Executable Statements ..
138 *
139  zqrt12 = zero
140 *
141 * Test that enough workspace is supplied
142 *
143  IF( lwork.LT.m*n+2*min( m, n )+max( m, n ) ) THEN
144  CALL xerbla( 'ZQRT12', 7 )
145  RETURN
146  END IF
147 *
148 * Quick return if possible
149 *
150  mn = min( m, n )
151  IF( mn.LE.zero )
152  $ RETURN
153 *
154  nrmsvl = dnrm2( mn, s, 1 )
155 *
156 * Copy upper triangle of A into work
157 *
158  CALL zlaset( 'Full', m, n, dcmplx( zero ), dcmplx( zero ), work,
159  $ m )
160  DO 20 j = 1, n
161  DO 10 i = 1, min( j, m )
162  work( ( j-1 )*m+i ) = a( i, j )
163  10 CONTINUE
164  20 CONTINUE
165 *
166 * Get machine parameters
167 *
168  smlnum = dlamch( 'S' ) / dlamch( 'P' )
169  bignum = one / smlnum
170  CALL dlabad( smlnum, bignum )
171 *
172 * Scale work if max entry outside range [SMLNUM,BIGNUM]
173 *
174  anrm = zlange( 'M', m, n, work, m, dummy )
175  iscl = 0
176  IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
177 *
178 * Scale matrix norm up to SMLNUM
179 *
180  CALL zlascl( 'G', 0, 0, anrm, smlnum, m, n, work, m, info )
181  iscl = 1
182  ELSE IF( anrm.GT.bignum ) THEN
183 *
184 * Scale matrix norm down to BIGNUM
185 *
186  CALL zlascl( 'G', 0, 0, anrm, bignum, m, n, work, m, info )
187  iscl = 1
188  END IF
189 *
190  IF( anrm.NE.zero ) THEN
191 *
192 * Compute SVD of work
193 *
194  CALL zgebd2( m, n, work, m, rwork( 1 ), rwork( mn+1 ),
195  $ work( m*n+1 ), work( m*n+mn+1 ),
196  $ work( m*n+2*mn+1 ), info )
197  CALL dbdsqr( 'Upper', mn, 0, 0, 0, rwork( 1 ), rwork( mn+1 ),
198  $ dummy, mn, dummy, 1, dummy, mn, rwork( 2*mn+1 ),
199  $ info )
200 *
201  IF( iscl.EQ.1 ) THEN
202  IF( anrm.GT.bignum ) THEN
203  CALL dlascl( 'G', 0, 0, bignum, anrm, mn, 1, rwork( 1 ),
204  $ mn, info )
205  END IF
206  IF( anrm.LT.smlnum ) THEN
207  CALL dlascl( 'G', 0, 0, smlnum, anrm, mn, 1, rwork( 1 ),
208  $ mn, info )
209  END IF
210  END IF
211 *
212  ELSE
213 *
214  DO 30 i = 1, mn
215  rwork( i ) = zero
216  30 CONTINUE
217  END IF
218 *
219 * Compare s and singular values of work
220 *
221  CALL daxpy( mn, -one, s, 1, rwork( 1 ), 1 )
222  zqrt12 = dasum( mn, rwork( 1 ), 1 ) /
223  $ ( dlamch( 'Epsilon' )*dble( max( m, n ) ) )
224  IF( nrmsvl.NE.zero )
225  $ zqrt12 = zqrt12 / nrmsvl
226 *
227  RETURN
228 *
229 * End of ZQRT12
230 *
231  END
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:145
subroutine zlascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: zlascl.f:145
subroutine daxpy(N, DA, DX, INCX, DY, INCY)
DAXPY
Definition: daxpy.f:91
subroutine dbdsqr(UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U, LDU, C, LDC, WORK, INFO)
DBDSQR
Definition: dbdsqr.f:243
double precision function zqrt12(M, N, A, LDA, S, WORK, LWORK, RWORK)
ZQRT12
Definition: zqrt12.f:99
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine zgebd2(M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO)
ZGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm.
Definition: zgebd2.f:191
subroutine zlaset(UPLO, M, N, ALPHA, BETA, A, LDA)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: zlaset.f:108
subroutine dlabad(SMALL, LARGE)
DLABAD
Definition: dlabad.f:76