PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cqrt15.f
Go to the documentation of this file.
1  SUBROUTINE cqrt15( SCALE, RKSEL, M, N, NRHS, A, LDA, B, LDB, S,
2  $ rank, norma, normb, iseed, work, lwork )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  INTEGER lda, ldb, lwork, m, n, nrhs, rank, rksel, scale
10  REAL norma, normb
11 * ..
12 * .. Array Arguments ..
13  INTEGER iseed( 4 )
14  REAL s( * )
15  COMPLEX a( lda, * ), b( ldb, * ), work( lwork )
16 * ..
17 *
18 * Purpose
19 * =======
20 *
21 * CQRT15 generates a matrix with full or deficient rank and of various
22 * norms.
23 *
24 * Arguments
25 * =========
26 *
27 * SCALE (input) INTEGER
28 * SCALE = 1: normally scaled matrix
29 * SCALE = 2: matrix scaled up
30 * SCALE = 3: matrix scaled down
31 *
32 * RKSEL (input) INTEGER
33 * RKSEL = 1: full rank matrix
34 * RKSEL = 2: rank-deficient matrix
35 *
36 * M (input) INTEGER
37 * The number of rows of the matrix A.
38 *
39 * N (input) INTEGER
40 * The number of columns of A.
41 *
42 * NRHS (input) INTEGER
43 * The number of columns of B.
44 *
45 * A (output) COMPLEX array, dimension (LDA,N)
46 * The M-by-N matrix A.
47 *
48 * LDA (input) INTEGER
49 * The leading dimension of the array A.
50 *
51 * B (output) COMPLEX array, dimension (LDB, NRHS)
52 * A matrix that is in the range space of matrix A.
53 *
54 * LDB (input) INTEGER
55 * The leading dimension of the array B.
56 *
57 * S (output) REAL array, dimension MIN(M,N)
58 * Singular values of A.
59 *
60 * RANK (output) INTEGER
61 * number of nonzero singular values of A.
62 *
63 * NORMA (output) REAL
64 * one-norm norm of A.
65 *
66 * NORMB (output) REAL
67 * one-norm norm of B.
68 *
69 * ISEED (input/output) integer array, dimension (4)
70 * seed for random number generator.
71 *
72 * WORK (workspace) COMPLEX array, dimension (LWORK)
73 *
74 * LWORK (input) INTEGER
75 * length of work space required.
76 * LWORK >= MAX(M+MIN(M,N),NRHS*MIN(M,N),2*N+M)
77 *
78 * =====================================================================
79 *
80 * .. Parameters ..
81  REAL zero, one, two, svmin
82  parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0,
83  $ svmin = 0.1e+0 )
84  COMPLEX czero, cone
85  parameter( czero = ( 0.0e+0, 0.0e+0 ),
86  $ cone = ( 1.0e+0, 0.0e+0 ) )
87 * ..
88 * .. Local Scalars ..
89  INTEGER info, j, mn
90  REAL bignum, eps, smlnum, temp
91 * ..
92 * .. Local Arrays ..
93  REAL dummy( 1 )
94 * ..
95 * .. External Functions ..
96  REAL clange, sasum, scnrm2, slamch, slarnd
97  EXTERNAL clange, sasum, scnrm2, slamch, slarnd
98 * ..
99 * .. External Subroutines ..
100  EXTERNAL cgemm, clarf, clarnv, claror, clascl, claset,
101  $ csscal, slabad, slaord, slascl, xerbla
102 * ..
103 * .. Intrinsic Functions ..
104  INTRINSIC abs, cmplx, max, min
105 * ..
106 * .. Executable Statements ..
107 *
108  mn = min( m, n )
109  IF( lwork.LT.max( m+mn, mn*nrhs, 2*n+m ) ) THEN
110  CALL xerbla( 'CQRT15', 16 )
111  return
112  END IF
113 *
114  smlnum = slamch( 'Safe minimum' )
115  bignum = one / smlnum
116  CALL slabad( smlnum, bignum )
117  eps = slamch( 'Epsilon' )
118  smlnum = ( smlnum / eps ) / eps
119  bignum = one / smlnum
120 *
121 * Determine rank and (unscaled) singular values
122 *
123  IF( rksel.EQ.1 ) THEN
124  rank = mn
125  ELSE IF( rksel.EQ.2 ) THEN
126  rank = ( 3*mn ) / 4
127  DO 10 j = rank + 1, mn
128  s( j ) = zero
129  10 continue
130  ELSE
131  CALL xerbla( 'CQRT15', 2 )
132  END IF
133 *
134  IF( rank.GT.0 ) THEN
135 *
136 * Nontrivial case
137 *
138  s( 1 ) = one
139  DO 30 j = 2, rank
140  20 continue
141  temp = slarnd( 1, iseed )
142  IF( temp.GT.svmin ) THEN
143  s( j ) = abs( temp )
144  ELSE
145  go to 20
146  END IF
147  30 continue
148  CALL slaord( 'Decreasing', rank, s, 1 )
149 *
150 * Generate 'rank' columns of a random orthogonal matrix in A
151 *
152  CALL clarnv( 2, iseed, m, work )
153  CALL csscal( m, one / scnrm2( m, work, 1 ), work, 1 )
154  CALL claset( 'Full', m, rank, czero, cone, a, lda )
155  CALL clarf( 'Left', m, rank, work, 1, cmplx( two ), a, lda,
156  $ work( m+1 ) )
157 *
158 * workspace used: m+mn
159 *
160 * Generate consistent rhs in the range space of A
161 *
162  CALL clarnv( 2, iseed, rank*nrhs, work )
163  CALL cgemm( 'No transpose', 'No transpose', m, nrhs, rank,
164  $ cone, a, lda, work, rank, czero, b, ldb )
165 *
166 * work space used: <= mn *nrhs
167 *
168 * generate (unscaled) matrix A
169 *
170  DO 40 j = 1, rank
171  CALL csscal( m, s( j ), a( 1, j ), 1 )
172  40 continue
173  IF( rank.LT.n )
174  $ CALL claset( 'Full', m, n-rank, czero, czero,
175  $ a( 1, rank+1 ), lda )
176  CALL claror( 'Right', 'No initialization', m, n, a, lda, iseed,
177  $ work, info )
178 *
179  ELSE
180 *
181 * work space used 2*n+m
182 *
183 * Generate null matrix and rhs
184 *
185  DO 50 j = 1, mn
186  s( j ) = zero
187  50 continue
188  CALL claset( 'Full', m, n, czero, czero, a, lda )
189  CALL claset( 'Full', m, nrhs, czero, czero, b, ldb )
190 *
191  END IF
192 *
193 * Scale the matrix
194 *
195  IF( scale.NE.1 ) THEN
196  norma = clange( 'Max', m, n, a, lda, dummy )
197  IF( norma.NE.zero ) THEN
198  IF( scale.EQ.2 ) THEN
199 *
200 * matrix scaled up
201 *
202  CALL clascl( 'General', 0, 0, norma, bignum, m, n, a,
203  $ lda, info )
204  CALL slascl( 'General', 0, 0, norma, bignum, mn, 1, s,
205  $ mn, info )
206  CALL clascl( 'General', 0, 0, norma, bignum, m, nrhs, b,
207  $ ldb, info )
208  ELSE IF( scale.EQ.3 ) THEN
209 *
210 * matrix scaled down
211 *
212  CALL clascl( 'General', 0, 0, norma, smlnum, m, n, a,
213  $ lda, info )
214  CALL slascl( 'General', 0, 0, norma, smlnum, mn, 1, s,
215  $ mn, info )
216  CALL clascl( 'General', 0, 0, norma, smlnum, m, nrhs, b,
217  $ ldb, info )
218  ELSE
219  CALL xerbla( 'CQRT15', 1 )
220  return
221  END IF
222  END IF
223  END IF
224 *
225  norma = sasum( mn, s, 1 )
226  normb = clange( 'One-norm', m, nrhs, b, ldb, dummy )
227 *
228  return
229 *
230 * End of CQRT15
231 *
232  END