LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
dqrt15.f
Go to the documentation of this file.
1 *> \brief \b DQRT15
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE DQRT15( SCALE, RKSEL, M, N, NRHS, A, LDA, B, LDB, S,
12 * RANK, NORMA, NORMB, ISEED, WORK, LWORK )
13 *
14 * .. Scalar Arguments ..
15 * INTEGER LDA, LDB, LWORK, M, N, NRHS, RANK, RKSEL, SCALE
16 * DOUBLE PRECISION NORMA, NORMB
17 * ..
18 * .. Array Arguments ..
19 * INTEGER ISEED( 4 )
20 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), S( * ), WORK( LWORK )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> DQRT15 generates a matrix with full or deficient rank and of various
30 *> norms.
31 *> \endverbatim
32 *
33 * Arguments:
34 * ==========
35 *
36 *> \param[in] SCALE
37 *> \verbatim
38 *> SCALE is INTEGER
39 *> SCALE = 1: normally scaled matrix
40 *> SCALE = 2: matrix scaled up
41 *> SCALE = 3: matrix scaled down
42 *> \endverbatim
43 *>
44 *> \param[in] RKSEL
45 *> \verbatim
46 *> RKSEL is INTEGER
47 *> RKSEL = 1: full rank matrix
48 *> RKSEL = 2: rank-deficient matrix
49 *> \endverbatim
50 *>
51 *> \param[in] M
52 *> \verbatim
53 *> M is INTEGER
54 *> The number of rows of the matrix A.
55 *> \endverbatim
56 *>
57 *> \param[in] N
58 *> \verbatim
59 *> N is INTEGER
60 *> The number of columns of A.
61 *> \endverbatim
62 *>
63 *> \param[in] NRHS
64 *> \verbatim
65 *> NRHS is INTEGER
66 *> The number of columns of B.
67 *> \endverbatim
68 *>
69 *> \param[out] A
70 *> \verbatim
71 *> A is DOUBLE PRECISION array, dimension (LDA,N)
72 *> The M-by-N matrix A.
73 *> \endverbatim
74 *>
75 *> \param[in] LDA
76 *> \verbatim
77 *> LDA is INTEGER
78 *> The leading dimension of the array A.
79 *> \endverbatim
80 *>
81 *> \param[out] B
82 *> \verbatim
83 *> B is DOUBLE PRECISION array, dimension (LDB, NRHS)
84 *> A matrix that is in the range space of matrix A.
85 *> \endverbatim
86 *>
87 *> \param[in] LDB
88 *> \verbatim
89 *> LDB is INTEGER
90 *> The leading dimension of the array B.
91 *> \endverbatim
92 *>
93 *> \param[out] S
94 *> \verbatim
95 *> S is DOUBLE PRECISION array, dimension MIN(M,N)
96 *> Singular values of A.
97 *> \endverbatim
98 *>
99 *> \param[out] RANK
100 *> \verbatim
101 *> RANK is INTEGER
102 *> number of nonzero singular values of A.
103 *> \endverbatim
104 *>
105 *> \param[out] NORMA
106 *> \verbatim
107 *> NORMA is DOUBLE PRECISION
108 *> one-norm of A.
109 *> \endverbatim
110 *>
111 *> \param[out] NORMB
112 *> \verbatim
113 *> NORMB is DOUBLE PRECISION
114 *> one-norm of B.
115 *> \endverbatim
116 *>
117 *> \param[in,out] ISEED
118 *> \verbatim
119 *> ISEED is integer array, dimension (4)
120 *> seed for random number generator.
121 *> \endverbatim
122 *>
123 *> \param[out] WORK
124 *> \verbatim
125 *> WORK is DOUBLE PRECISION array, dimension (LWORK)
126 *> \endverbatim
127 *>
128 *> \param[in] LWORK
129 *> \verbatim
130 *> LWORK is INTEGER
131 *> length of work space required.
132 *> LWORK >= MAX(M+MIN(M,N),NRHS*MIN(M,N),2*N+M)
133 *> \endverbatim
134 *
135 * Authors:
136 * ========
137 *
138 *> \author Univ. of Tennessee
139 *> \author Univ. of California Berkeley
140 *> \author Univ. of Colorado Denver
141 *> \author NAG Ltd.
142 *
143 *> \date November 2011
144 *
145 *> \ingroup double_lin
146 *
147 * =====================================================================
148  SUBROUTINE dqrt15( SCALE, RKSEL, M, N, NRHS, A, LDA, B, LDB, S,
149  $ rank, norma, normb, iseed, work, lwork )
150 *
151 * -- LAPACK test routine (version 3.4.0) --
152 * -- LAPACK is a software package provided by Univ. of Tennessee, --
153 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
154 * November 2011
155 *
156 * .. Scalar Arguments ..
157  INTEGER LDA, LDB, LWORK, M, N, NRHS, RANK, RKSEL, SCALE
158  DOUBLE PRECISION NORMA, NORMB
159 * ..
160 * .. Array Arguments ..
161  INTEGER ISEED( 4 )
162  DOUBLE PRECISION A( lda, * ), B( ldb, * ), S( * ), WORK( lwork )
163 * ..
164 *
165 * =====================================================================
166 *
167 * .. Parameters ..
168  DOUBLE PRECISION ZERO, ONE, TWO, SVMIN
169  parameter ( zero = 0.0d0, one = 1.0d0, two = 2.0d0,
170  $ svmin = 0.1d0 )
171 * ..
172 * .. Local Scalars ..
173  INTEGER INFO, J, MN
174  DOUBLE PRECISION BIGNUM, EPS, SMLNUM, TEMP
175 * ..
176 * .. Local Arrays ..
177  DOUBLE PRECISION DUMMY( 1 )
178 * ..
179 * .. External Functions ..
180  DOUBLE PRECISION DASUM, DLAMCH, DLANGE, DLARND, DNRM2
181  EXTERNAL dasum, dlamch, dlange, dlarnd, dnrm2
182 * ..
183 * .. External Subroutines ..
184  EXTERNAL dgemm, dlaord, dlarf, dlarnv, dlaror, dlascl,
185  $ dlaset, dscal, xerbla
186 * ..
187 * .. Intrinsic Functions ..
188  INTRINSIC abs, max, min
189 * ..
190 * .. Executable Statements ..
191 *
192  mn = min( m, n )
193  IF( lwork.LT.max( m+mn, mn*nrhs, 2*n+m ) ) THEN
194  CALL xerbla( 'DQRT15', 16 )
195  RETURN
196  END IF
197 *
198  smlnum = dlamch( 'Safe minimum' )
199  bignum = one / smlnum
200  eps = dlamch( 'Epsilon' )
201  smlnum = ( smlnum / eps ) / eps
202  bignum = one / smlnum
203 *
204 * Determine rank and (unscaled) singular values
205 *
206  IF( rksel.EQ.1 ) THEN
207  rank = mn
208  ELSE IF( rksel.EQ.2 ) THEN
209  rank = ( 3*mn ) / 4
210  DO 10 j = rank + 1, mn
211  s( j ) = zero
212  10 CONTINUE
213  ELSE
214  CALL xerbla( 'DQRT15', 2 )
215  END IF
216 *
217  IF( rank.GT.0 ) THEN
218 *
219 * Nontrivial case
220 *
221  s( 1 ) = one
222  DO 30 j = 2, rank
223  20 CONTINUE
224  temp = dlarnd( 1, iseed )
225  IF( temp.GT.svmin ) THEN
226  s( j ) = abs( temp )
227  ELSE
228  GO TO 20
229  END IF
230  30 CONTINUE
231  CALL dlaord( 'Decreasing', rank, s, 1 )
232 *
233 * Generate 'rank' columns of a random orthogonal matrix in A
234 *
235  CALL dlarnv( 2, iseed, m, work )
236  CALL dscal( m, one / dnrm2( m, work, 1 ), work, 1 )
237  CALL dlaset( 'Full', m, rank, zero, one, a, lda )
238  CALL dlarf( 'Left', m, rank, work, 1, two, a, lda,
239  $ work( m+1 ) )
240 *
241 * workspace used: m+mn
242 *
243 * Generate consistent rhs in the range space of A
244 *
245  CALL dlarnv( 2, iseed, rank*nrhs, work )
246  CALL dgemm( 'No transpose', 'No transpose', m, nrhs, rank, one,
247  $ a, lda, work, rank, zero, b, ldb )
248 *
249 * work space used: <= mn *nrhs
250 *
251 * generate (unscaled) matrix A
252 *
253  DO 40 j = 1, rank
254  CALL dscal( m, s( j ), a( 1, j ), 1 )
255  40 CONTINUE
256  IF( rank.LT.n )
257  $ CALL dlaset( 'Full', m, n-rank, zero, zero, a( 1, rank+1 ),
258  $ lda )
259  CALL dlaror( 'Right', 'No initialization', m, n, a, lda, iseed,
260  $ work, info )
261 *
262  ELSE
263 *
264 * work space used 2*n+m
265 *
266 * Generate null matrix and rhs
267 *
268  DO 50 j = 1, mn
269  s( j ) = zero
270  50 CONTINUE
271  CALL dlaset( 'Full', m, n, zero, zero, a, lda )
272  CALL dlaset( 'Full', m, nrhs, zero, zero, b, ldb )
273 *
274  END IF
275 *
276 * Scale the matrix
277 *
278  IF( scale.NE.1 ) THEN
279  norma = dlange( 'Max', m, n, a, lda, dummy )
280  IF( norma.NE.zero ) THEN
281  IF( scale.EQ.2 ) THEN
282 *
283 * matrix scaled up
284 *
285  CALL dlascl( 'General', 0, 0, norma, bignum, m, n, a,
286  $ lda, info )
287  CALL dlascl( 'General', 0, 0, norma, bignum, mn, 1, s,
288  $ mn, info )
289  CALL dlascl( 'General', 0, 0, norma, bignum, m, nrhs, b,
290  $ ldb, info )
291  ELSE IF( scale.EQ.3 ) THEN
292 *
293 * matrix scaled down
294 *
295  CALL dlascl( 'General', 0, 0, norma, smlnum, m, n, a,
296  $ lda, info )
297  CALL dlascl( 'General', 0, 0, norma, smlnum, mn, 1, s,
298  $ mn, info )
299  CALL dlascl( 'General', 0, 0, norma, smlnum, m, nrhs, b,
300  $ ldb, info )
301  ELSE
302  CALL xerbla( 'DQRT15', 1 )
303  RETURN
304  END IF
305  END IF
306  END IF
307 *
308  norma = dasum( mn, s, 1 )
309  normb = dlange( 'One-norm', m, nrhs, b, ldb, dummy )
310 *
311  RETURN
312 *
313 * End of DQRT15
314 *
315  END
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:112
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 dlaror(SIDE, INIT, M, N, A, LDA, ISEED, X, INFO)
DLAROR
Definition: dlaror.f:148
subroutine dlarf(SIDE, M, N, V, INCV, TAU, C, LDC, WORK)
DLARF applies an elementary reflector to a general rectangular matrix.
Definition: dlarf.f:126
subroutine dlaord(JOB, N, X, INCX)
DLAORD
Definition: dlaord.f:75
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DGEMM
Definition: dgemm.f:189
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine dqrt15(SCALE, RKSEL, M, N, NRHS, A, LDA, B, LDB, S, RANK, NORMA, NORMB, ISEED, WORK, LWORK)
DQRT15
Definition: dqrt15.f:150
subroutine dscal(N, DA, DX, INCX)
DSCAL
Definition: dscal.f:55
subroutine dlarnv(IDIST, ISEED, N, X)
DLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: dlarnv.f:99