LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
clagge.f
Go to the documentation of this file.
1 *> \brief \b CLAGGE
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 CLAGGE( M, N, KL, KU, D, A, LDA, ISEED, WORK, INFO )
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INFO, KL, KU, LDA, M, N
15 * ..
16 * .. Array Arguments ..
17 * INTEGER ISEED( 4 )
18 * REAL D( * )
19 * COMPLEX A( LDA, * ), WORK( * )
20 * ..
21 *
22 *
23 *> \par Purpose:
24 * =============
25 *>
26 *> \verbatim
27 *>
28 *> CLAGGE generates a complex general m by n matrix A, by pre- and post-
29 *> multiplying a real diagonal matrix D with random unitary matrices:
30 *> A = U*D*V. The lower and upper bandwidths may then be reduced to
31 *> kl and ku by additional unitary transformations.
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. M >= 0.
41 *> \endverbatim
42 *>
43 *> \param[in] N
44 *> \verbatim
45 *> N is INTEGER
46 *> The number of columns of the matrix A. N >= 0.
47 *> \endverbatim
48 *>
49 *> \param[in] KL
50 *> \verbatim
51 *> KL is INTEGER
52 *> The number of nonzero subdiagonals within the band of A.
53 *> 0 <= KL <= M-1.
54 *> \endverbatim
55 *>
56 *> \param[in] KU
57 *> \verbatim
58 *> KU is INTEGER
59 *> The number of nonzero superdiagonals within the band of A.
60 *> 0 <= KU <= N-1.
61 *> \endverbatim
62 *>
63 *> \param[in] D
64 *> \verbatim
65 *> D is REAL array, dimension (min(M,N))
66 *> The diagonal elements of the diagonal matrix D.
67 *> \endverbatim
68 *>
69 *> \param[out] A
70 *> \verbatim
71 *> A is COMPLEX array, dimension (LDA,N)
72 *> The generated 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. LDA >= M.
79 *> \endverbatim
80 *>
81 *> \param[in,out] ISEED
82 *> \verbatim
83 *> ISEED is INTEGER array, dimension (4)
84 *> On entry, the seed of the random number generator; the array
85 *> elements must be between 0 and 4095, and ISEED(4) must be
86 *> odd.
87 *> On exit, the seed is updated.
88 *> \endverbatim
89 *>
90 *> \param[out] WORK
91 *> \verbatim
92 *> WORK is COMPLEX array, dimension (M+N)
93 *> \endverbatim
94 *>
95 *> \param[out] INFO
96 *> \verbatim
97 *> INFO is INTEGER
98 *> = 0: successful exit
99 *> < 0: if INFO = -i, the i-th argument had an illegal value
100 *> \endverbatim
101 *
102 * Authors:
103 * ========
104 *
105 *> \author Univ. of Tennessee
106 *> \author Univ. of California Berkeley
107 *> \author Univ. of Colorado Denver
108 *> \author NAG Ltd.
109 *
110 *> \date November 2015
111 *
112 *> \ingroup complex_matgen
113 *
114 * =====================================================================
115  SUBROUTINE clagge( M, N, KL, KU, D, A, LDA, ISEED, WORK, INFO )
116 *
117 * -- LAPACK auxiliary routine (version 3.6.0) --
118 * -- LAPACK is a software package provided by Univ. of Tennessee, --
119 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
120 * November 2015
121 *
122 * .. Scalar Arguments ..
123  INTEGER INFO, KL, KU, LDA, M, N
124 * ..
125 * .. Array Arguments ..
126  INTEGER ISEED( 4 )
127  REAL D( * )
128  COMPLEX A( lda, * ), WORK( * )
129 * ..
130 *
131 * =====================================================================
132 *
133 * .. Parameters ..
134  COMPLEX ZERO, ONE
135  parameter ( zero = ( 0.0e+0, 0.0e+0 ),
136  $ one = ( 1.0e+0, 0.0e+0 ) )
137 * ..
138 * .. Local Scalars ..
139  INTEGER I, J
140  REAL WN
141  COMPLEX TAU, WA, WB
142 * ..
143 * .. External Subroutines ..
144  EXTERNAL cgemv, cgerc, clacgv, clarnv, cscal, xerbla
145 * ..
146 * .. Intrinsic Functions ..
147  INTRINSIC abs, max, min, real
148 * ..
149 * .. External Functions ..
150  REAL SCNRM2
151  EXTERNAL scnrm2
152 * ..
153 * .. Executable Statements ..
154 *
155 * Test the input arguments
156 *
157  info = 0
158  IF( m.LT.0 ) THEN
159  info = -1
160  ELSE IF( n.LT.0 ) THEN
161  info = -2
162  ELSE IF( kl.LT.0 .OR. kl.GT.m-1 ) THEN
163  info = -3
164  ELSE IF( ku.LT.0 .OR. ku.GT.n-1 ) THEN
165  info = -4
166  ELSE IF( lda.LT.max( 1, m ) ) THEN
167  info = -7
168  END IF
169  IF( info.LT.0 ) THEN
170  CALL xerbla( 'CLAGGE', -info )
171  RETURN
172  END IF
173 *
174 * initialize A to diagonal matrix
175 *
176  DO 20 j = 1, n
177  DO 10 i = 1, m
178  a( i, j ) = zero
179  10 CONTINUE
180  20 CONTINUE
181  DO 30 i = 1, min( m, n )
182  a( i, i ) = d( i )
183  30 CONTINUE
184 *
185 * Quick exit if the user wants a diagonal matrix
186 *
187  IF(( kl .EQ. 0 ).AND.( ku .EQ. 0)) RETURN
188 *
189 * pre- and post-multiply A by random unitary matrices
190 *
191  DO 40 i = min( m, n ), 1, -1
192  IF( i.LT.m ) THEN
193 *
194 * generate random reflection
195 *
196  CALL clarnv( 3, iseed, m-i+1, work )
197  wn = scnrm2( m-i+1, work, 1 )
198  wa = ( wn / abs( work( 1 ) ) )*work( 1 )
199  IF( wn.EQ.zero ) THEN
200  tau = zero
201  ELSE
202  wb = work( 1 ) + wa
203  CALL cscal( m-i, one / wb, work( 2 ), 1 )
204  work( 1 ) = one
205  tau = REAL( wb / wa )
206  END IF
207 *
208 * multiply A(i:m,i:n) by random reflection from the left
209 *
210  CALL cgemv( 'Conjugate transpose', m-i+1, n-i+1, one,
211  $ a( i, i ), lda, work, 1, zero, work( m+1 ), 1 )
212  CALL cgerc( m-i+1, n-i+1, -tau, work, 1, work( m+1 ), 1,
213  $ a( i, i ), lda )
214  END IF
215  IF( i.LT.n ) THEN
216 *
217 * generate random reflection
218 *
219  CALL clarnv( 3, iseed, n-i+1, work )
220  wn = scnrm2( n-i+1, work, 1 )
221  wa = ( wn / abs( work( 1 ) ) )*work( 1 )
222  IF( wn.EQ.zero ) THEN
223  tau = zero
224  ELSE
225  wb = work( 1 ) + wa
226  CALL cscal( n-i, one / wb, work( 2 ), 1 )
227  work( 1 ) = one
228  tau = REAL( wb / wa )
229  END IF
230 *
231 * multiply A(i:m,i:n) by random reflection from the right
232 *
233  CALL cgemv( 'No transpose', m-i+1, n-i+1, one, a( i, i ),
234  $ lda, work, 1, zero, work( n+1 ), 1 )
235  CALL cgerc( m-i+1, n-i+1, -tau, work( n+1 ), 1, work, 1,
236  $ a( i, i ), lda )
237  END IF
238  40 CONTINUE
239 *
240 * Reduce number of subdiagonals to KL and number of superdiagonals
241 * to KU
242 *
243  DO 70 i = 1, max( m-1-kl, n-1-ku )
244  IF( kl.LE.ku ) THEN
245 *
246 * annihilate subdiagonal elements first (necessary if KL = 0)
247 *
248  IF( i.LE.min( m-1-kl, n ) ) THEN
249 *
250 * generate reflection to annihilate A(kl+i+1:m,i)
251 *
252  wn = scnrm2( m-kl-i+1, a( kl+i, i ), 1 )
253  wa = ( wn / abs( a( kl+i, i ) ) )*a( kl+i, i )
254  IF( wn.EQ.zero ) THEN
255  tau = zero
256  ELSE
257  wb = a( kl+i, i ) + wa
258  CALL cscal( m-kl-i, one / wb, a( kl+i+1, i ), 1 )
259  a( kl+i, i ) = one
260  tau = REAL( wb / wa )
261  END IF
262 *
263 * apply reflection to A(kl+i:m,i+1:n) from the left
264 *
265  CALL cgemv( 'Conjugate transpose', m-kl-i+1, n-i, one,
266  $ a( kl+i, i+1 ), lda, a( kl+i, i ), 1, zero,
267  $ work, 1 )
268  CALL cgerc( m-kl-i+1, n-i, -tau, a( kl+i, i ), 1, work,
269  $ 1, a( kl+i, i+1 ), lda )
270  a( kl+i, i ) = -wa
271  END IF
272 *
273  IF( i.LE.min( n-1-ku, m ) ) THEN
274 *
275 * generate reflection to annihilate A(i,ku+i+1:n)
276 *
277  wn = scnrm2( n-ku-i+1, a( i, ku+i ), lda )
278  wa = ( wn / abs( a( i, ku+i ) ) )*a( i, ku+i )
279  IF( wn.EQ.zero ) THEN
280  tau = zero
281  ELSE
282  wb = a( i, ku+i ) + wa
283  CALL cscal( n-ku-i, one / wb, a( i, ku+i+1 ), lda )
284  a( i, ku+i ) = one
285  tau = REAL( wb / wa )
286  END IF
287 *
288 * apply reflection to A(i+1:m,ku+i:n) from the right
289 *
290  CALL clacgv( n-ku-i+1, a( i, ku+i ), lda )
291  CALL cgemv( 'No transpose', m-i, n-ku-i+1, one,
292  $ a( i+1, ku+i ), lda, a( i, ku+i ), lda, zero,
293  $ work, 1 )
294  CALL cgerc( m-i, n-ku-i+1, -tau, work, 1, a( i, ku+i ),
295  $ lda, a( i+1, ku+i ), lda )
296  a( i, ku+i ) = -wa
297  END IF
298  ELSE
299 *
300 * annihilate superdiagonal elements first (necessary if
301 * KU = 0)
302 *
303  IF( i.LE.min( n-1-ku, m ) ) THEN
304 *
305 * generate reflection to annihilate A(i,ku+i+1:n)
306 *
307  wn = scnrm2( n-ku-i+1, a( i, ku+i ), lda )
308  wa = ( wn / abs( a( i, ku+i ) ) )*a( i, ku+i )
309  IF( wn.EQ.zero ) THEN
310  tau = zero
311  ELSE
312  wb = a( i, ku+i ) + wa
313  CALL cscal( n-ku-i, one / wb, a( i, ku+i+1 ), lda )
314  a( i, ku+i ) = one
315  tau = REAL( wb / wa )
316  END IF
317 *
318 * apply reflection to A(i+1:m,ku+i:n) from the right
319 *
320  CALL clacgv( n-ku-i+1, a( i, ku+i ), lda )
321  CALL cgemv( 'No transpose', m-i, n-ku-i+1, one,
322  $ a( i+1, ku+i ), lda, a( i, ku+i ), lda, zero,
323  $ work, 1 )
324  CALL cgerc( m-i, n-ku-i+1, -tau, work, 1, a( i, ku+i ),
325  $ lda, a( i+1, ku+i ), lda )
326  a( i, ku+i ) = -wa
327  END IF
328 *
329  IF( i.LE.min( m-1-kl, n ) ) THEN
330 *
331 * generate reflection to annihilate A(kl+i+1:m,i)
332 *
333  wn = scnrm2( m-kl-i+1, a( kl+i, i ), 1 )
334  wa = ( wn / abs( a( kl+i, i ) ) )*a( kl+i, i )
335  IF( wn.EQ.zero ) THEN
336  tau = zero
337  ELSE
338  wb = a( kl+i, i ) + wa
339  CALL cscal( m-kl-i, one / wb, a( kl+i+1, i ), 1 )
340  a( kl+i, i ) = one
341  tau = REAL( wb / wa )
342  END IF
343 *
344 * apply reflection to A(kl+i:m,i+1:n) from the left
345 *
346  CALL cgemv( 'Conjugate transpose', m-kl-i+1, n-i, one,
347  $ a( kl+i, i+1 ), lda, a( kl+i, i ), 1, zero,
348  $ work, 1 )
349  CALL cgerc( m-kl-i+1, n-i, -tau, a( kl+i, i ), 1, work,
350  $ 1, a( kl+i, i+1 ), lda )
351  a( kl+i, i ) = -wa
352  END IF
353  END IF
354 *
355  IF (i .LE. n) THEN
356  DO 50 j = kl + i + 1, m
357  a( j, i ) = zero
358  50 CONTINUE
359  END IF
360 *
361  IF (i .LE. m) THEN
362  DO 60 j = ku + i + 1, n
363  a( i, j ) = zero
364  60 CONTINUE
365  END IF
366  70 CONTINUE
367  RETURN
368 *
369 * End of CLAGGE
370 *
371  END
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine cscal(N, CA, CX, INCX)
CSCAL
Definition: cscal.f:54
subroutine cgemv(TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CGEMV
Definition: cgemv.f:160
subroutine clarnv(IDIST, ISEED, N, X)
CLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: clarnv.f:101
subroutine cgerc(M, N, ALPHA, X, INCX, Y, INCY, A, LDA)
CGERC
Definition: cgerc.f:132
subroutine clacgv(N, X, INCX)
CLACGV conjugates a complex vector.
Definition: clacgv.f:76
subroutine clagge(M, N, KL, KU, D, A, LDA, ISEED, WORK, INFO)
CLAGGE
Definition: clagge.f:116