ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
dlagge.f
Go to the documentation of this file.
1  SUBROUTINE dlagge( M, N, KL, KU, D, A, LDA, ISEED, WORK, INFO )
2 *
3 * -- LAPACK auxiliary test routine (version 3.1)
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  INTEGER INFO, KL, KU, LDA, M, N
9 * ..
10 * .. Array Arguments ..
11  INTEGER ISEED( 4 )
12  DOUBLE PRECISION A( LDA, * ), D( * ), WORK( * )
13 * ..
14 *
15 * Purpose
16 * =======
17 *
18 * DLAGGE generates a real general m by n matrix A, by pre- and post-
19 * multiplying a real diagonal matrix D with random orthogonal matrices:
20 * A = U*D*V. The lower and upper bandwidths may then be reduced to
21 * kl and ku by additional orthogonal transformations.
22 *
23 * Arguments
24 * =========
25 *
26 * M (input) INTEGER
27 * The number of rows of the matrix A. M >= 0.
28 *
29 * N (input) INTEGER
30 * The number of columns of the matrix A. N >= 0.
31 *
32 * KL (input) INTEGER
33 * The number of nonzero subdiagonals within the band of A.
34 * 0 <= KL <= M-1.
35 *
36 * KU (input) INTEGER
37 * The number of nonzero superdiagonals within the band of A.
38 * 0 <= KU <= N-1.
39 *
40 * D (input) DOUBLE PRECISION array, dimension (min(M,N))
41 * The diagonal elements of the diagonal matrix D.
42 *
43 * A (output) DOUBLE PRECISION array, dimension (LDA,N)
44 * The generated m by n matrix A.
45 *
46 * LDA (input) INTEGER
47 * The leading dimension of the array A. LDA >= M.
48 *
49 * ISEED (input/output) INTEGER array, dimension (4)
50 * On entry, the seed of the random number generator; the array
51 * elements must be between 0 and 4095, and ISEED(4) must be
52 * odd.
53 * On exit, the seed is updated.
54 *
55 * WORK (workspace) DOUBLE PRECISION array, dimension (M+N)
56 *
57 * INFO (output) INTEGER
58 * = 0: successful exit
59 * < 0: if INFO = -i, the i-th argument had an illegal value
60 *
61 * =====================================================================
62 *
63 * .. Parameters ..
64  DOUBLE PRECISION ZERO, ONE
65  parameter( zero = 0.0d+0, one = 1.0d+0 )
66 * ..
67 * .. Local Scalars ..
68  INTEGER I, J
69  DOUBLE PRECISION TAU, WA, WB, WN
70 * ..
71 * .. External Subroutines ..
72  EXTERNAL dgemv, dger, dlarnv, dscal, xerbla
73 * ..
74 * .. Intrinsic Functions ..
75  INTRINSIC max, min, sign
76 * ..
77 * .. External Functions ..
78  DOUBLE PRECISION DNRM2
79  EXTERNAL dnrm2
80 * ..
81 * .. Executable Statements ..
82 *
83 * Test the input arguments
84 *
85  info = 0
86  IF( m.LT.0 ) THEN
87  info = -1
88  ELSE IF( n.LT.0 ) THEN
89  info = -2
90  ELSE IF( kl.LT.0 .OR. kl.GT.m-1 ) THEN
91  info = -3
92  ELSE IF( ku.LT.0 .OR. ku.GT.n-1 ) THEN
93  info = -4
94  ELSE IF( lda.LT.max( 1, m ) ) THEN
95  info = -7
96  END IF
97  IF( info.LT.0 ) THEN
98  CALL xerbla( 'DLAGGE', -info )
99  RETURN
100  END IF
101 *
102 * initialize A to diagonal matrix
103 *
104  DO 20 j = 1, n
105  DO 10 i = 1, m
106  a( i, j ) = zero
107  10 CONTINUE
108  20 CONTINUE
109  DO 30 i = 1, min( m, n )
110  a( i, i ) = d( i )
111  30 CONTINUE
112 *
113 * pre- and post-multiply A by random orthogonal matrices
114 *
115  DO 40 i = min( m, n ), 1, -1
116  IF( i.LT.m ) THEN
117 *
118 * generate random reflection
119 *
120  CALL dlarnv( 3, iseed, m-i+1, work )
121  wn = dnrm2( m-i+1, work, 1 )
122  wa = sign( wn, work( 1 ) )
123  IF( wn.EQ.zero ) THEN
124  tau = zero
125  ELSE
126  wb = work( 1 ) + wa
127  CALL dscal( m-i, one / wb, work( 2 ), 1 )
128  work( 1 ) = one
129  tau = wb / wa
130  END IF
131 *
132 * multiply A(i:m,i:n) by random reflection from the left
133 *
134  CALL dgemv( 'Transpose', m-i+1, n-i+1, one, a( i, i ), lda,
135  $ work, 1, zero, work( m+1 ), 1 )
136  CALL dger( m-i+1, n-i+1, -tau, work, 1, work( m+1 ), 1,
137  $ a( i, i ), lda )
138  END IF
139  IF( i.LT.n ) THEN
140 *
141 * generate random reflection
142 *
143  CALL dlarnv( 3, iseed, n-i+1, work )
144  wn = dnrm2( n-i+1, work, 1 )
145  wa = sign( wn, work( 1 ) )
146  IF( wn.EQ.zero ) THEN
147  tau = zero
148  ELSE
149  wb = work( 1 ) + wa
150  CALL dscal( n-i, one / wb, work( 2 ), 1 )
151  work( 1 ) = one
152  tau = wb / wa
153  END IF
154 *
155 * multiply A(i:m,i:n) by random reflection from the right
156 *
157  CALL dgemv( 'No transpose', m-i+1, n-i+1, one, a( i, i ),
158  $ lda, work, 1, zero, work( n+1 ), 1 )
159  CALL dger( m-i+1, n-i+1, -tau, work( n+1 ), 1, work, 1,
160  $ a( i, i ), lda )
161  END IF
162  40 CONTINUE
163 *
164 * Reduce number of subdiagonals to KL and number of superdiagonals
165 * to KU
166 *
167  DO 70 i = 1, max( m-1-kl, n-1-ku )
168  IF( kl.LE.ku ) THEN
169 *
170 * annihilate subdiagonal elements first (necessary if KL = 0)
171 *
172  IF( i.LE.min( m-1-kl, n ) ) THEN
173 *
174 * generate reflection to annihilate A(kl+i+1:m,i)
175 *
176  wn = dnrm2( m-kl-i+1, a( kl+i, i ), 1 )
177  wa = sign( wn, a( kl+i, i ) )
178  IF( wn.EQ.zero ) THEN
179  tau = zero
180  ELSE
181  wb = a( kl+i, i ) + wa
182  CALL dscal( m-kl-i, one / wb, a( kl+i+1, i ), 1 )
183  a( kl+i, i ) = one
184  tau = wb / wa
185  END IF
186 *
187 * apply reflection to A(kl+i:m,i+1:n) from the left
188 *
189  CALL dgemv( 'Transpose', m-kl-i+1, n-i, one,
190  $ a( kl+i, i+1 ), lda, a( kl+i, i ), 1, zero,
191  $ work, 1 )
192  CALL dger( m-kl-i+1, n-i, -tau, a( kl+i, i ), 1, work, 1,
193  $ a( kl+i, i+1 ), lda )
194  a( kl+i, i ) = -wa
195  END IF
196 *
197  IF( i.LE.min( n-1-ku, m ) ) THEN
198 *
199 * generate reflection to annihilate A(i,ku+i+1:n)
200 *
201  wn = dnrm2( n-ku-i+1, a( i, ku+i ), lda )
202  wa = sign( wn, a( i, ku+i ) )
203  IF( wn.EQ.zero ) THEN
204  tau = zero
205  ELSE
206  wb = a( i, ku+i ) + wa
207  CALL dscal( n-ku-i, one / wb, a( i, ku+i+1 ), lda )
208  a( i, ku+i ) = one
209  tau = wb / wa
210  END IF
211 *
212 * apply reflection to A(i+1:m,ku+i:n) from the right
213 *
214  CALL dgemv( 'No transpose', m-i, n-ku-i+1, one,
215  $ a( i+1, ku+i ), lda, a( i, ku+i ), lda, zero,
216  $ work, 1 )
217  CALL dger( m-i, n-ku-i+1, -tau, work, 1, a( i, ku+i ),
218  $ lda, a( i+1, ku+i ), lda )
219  a( i, ku+i ) = -wa
220  END IF
221  ELSE
222 *
223 * annihilate superdiagonal elements first (necessary if
224 * KU = 0)
225 *
226  IF( i.LE.min( n-1-ku, m ) ) THEN
227 *
228 * generate reflection to annihilate A(i,ku+i+1:n)
229 *
230  wn = dnrm2( n-ku-i+1, a( i, ku+i ), lda )
231  wa = sign( wn, a( i, ku+i ) )
232  IF( wn.EQ.zero ) THEN
233  tau = zero
234  ELSE
235  wb = a( i, ku+i ) + wa
236  CALL dscal( n-ku-i, one / wb, a( i, ku+i+1 ), lda )
237  a( i, ku+i ) = one
238  tau = wb / wa
239  END IF
240 *
241 * apply reflection to A(i+1:m,ku+i:n) from the right
242 *
243  CALL dgemv( 'No transpose', m-i, n-ku-i+1, one,
244  $ a( i+1, ku+i ), lda, a( i, ku+i ), lda, zero,
245  $ work, 1 )
246  CALL dger( m-i, n-ku-i+1, -tau, work, 1, a( i, ku+i ),
247  $ lda, a( i+1, ku+i ), lda )
248  a( i, ku+i ) = -wa
249  END IF
250 *
251  IF( i.LE.min( m-1-kl, n ) ) THEN
252 *
253 * generate reflection to annihilate A(kl+i+1:m,i)
254 *
255  wn = dnrm2( m-kl-i+1, a( kl+i, i ), 1 )
256  wa = sign( wn, a( kl+i, i ) )
257  IF( wn.EQ.zero ) THEN
258  tau = zero
259  ELSE
260  wb = a( kl+i, i ) + wa
261  CALL dscal( m-kl-i, one / wb, a( kl+i+1, i ), 1 )
262  a( kl+i, i ) = one
263  tau = wb / wa
264  END IF
265 *
266 * apply reflection to A(kl+i:m,i+1:n) from the left
267 *
268  CALL dgemv( 'Transpose', m-kl-i+1, n-i, one,
269  $ a( kl+i, i+1 ), lda, a( kl+i, i ), 1, zero,
270  $ work, 1 )
271  CALL dger( m-kl-i+1, n-i, -tau, a( kl+i, i ), 1, work, 1,
272  $ a( kl+i, i+1 ), lda )
273  a( kl+i, i ) = -wa
274  END IF
275  END IF
276 *
277  DO 50 j = kl + i + 1, m
278  a( j, i ) = zero
279  50 CONTINUE
280 *
281  DO 60 j = ku + i + 1, n
282  a( i, j ) = zero
283  60 CONTINUE
284  70 CONTINUE
285  RETURN
286 *
287 * End of DLAGGE
288 *
289  END
max
#define max(A, B)
Definition: pcgemr.c:180
dlagge
subroutine dlagge(M, N, KL, KU, D, A, LDA, ISEED, WORK, INFO)
Definition: dlagge.f:2
min
#define min(A, B)
Definition: pcgemr.c:181