LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine clagge ( integer  M,
integer  N,
integer  KL,
integer  KU,
real, dimension( * )  D,
complex, dimension( lda, * )  A,
integer  LDA,
integer, dimension( 4 )  ISEED,
complex, dimension( * )  WORK,
integer  INFO 
)

CLAGGE

Purpose:
 CLAGGE generates a complex general m by n matrix A, by pre- and post-
 multiplying a real diagonal matrix D with random unitary matrices:
 A = U*D*V. The lower and upper bandwidths may then be reduced to
 kl and ku by additional unitary transformations.
Parameters
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrix A.  N >= 0.
[in]KL
          KL is INTEGER
          The number of nonzero subdiagonals within the band of A.
          0 <= KL <= M-1.
[in]KU
          KU is INTEGER
          The number of nonzero superdiagonals within the band of A.
          0 <= KU <= N-1.
[in]D
          D is REAL array, dimension (min(M,N))
          The diagonal elements of the diagonal matrix D.
[out]A
          A is COMPLEX array, dimension (LDA,N)
          The generated m by n matrix A.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= M.
[in,out]ISEED
          ISEED is INTEGER array, dimension (4)
          On entry, the seed of the random number generator; the array
          elements must be between 0 and 4095, and ISEED(4) must be
          odd.
          On exit, the seed is updated.
[out]WORK
          WORK is COMPLEX array, dimension (M+N)
[out]INFO
          INFO is INTEGER
          = 0: successful exit
          < 0: if INFO = -i, the i-th argument had an illegal value
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2015

Definition at line 116 of file clagge.f.

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 *
real function scnrm2(N, X, INCX)
SCNRM2
Definition: scnrm2.f:56
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

Here is the call graph for this function:

Here is the caller graph for this function: