LAPACK 3.3.0

clagge.f

Go to the documentation of this file.
00001       SUBROUTINE CLAGGE( M, N, KL, KU, D, A, LDA, ISEED, WORK, INFO )
00002 *
00003 *  -- LAPACK auxiliary test routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     November 2006
00006 *
00007 *     .. Scalar Arguments ..
00008       INTEGER            INFO, KL, KU, LDA, M, N
00009 *     ..
00010 *     .. Array Arguments ..
00011       INTEGER            ISEED( 4 )
00012       REAL               D( * )
00013       COMPLEX            A( LDA, * ), WORK( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  CLAGGE generates a complex general m by n matrix A, by pre- and post-
00020 *  multiplying a real diagonal matrix D with random unitary matrices:
00021 *  A = U*D*V. The lower and upper bandwidths may then be reduced to
00022 *  kl and ku by additional unitary transformations.
00023 *
00024 *  Arguments
00025 *  =========
00026 *
00027 *  M       (input) INTEGER
00028 *          The number of rows of the matrix A.  M >= 0.
00029 *
00030 *  N       (input) INTEGER
00031 *          The number of columns of the matrix A.  N >= 0.
00032 *
00033 *  KL      (input) INTEGER
00034 *          The number of nonzero subdiagonals within the band of A.
00035 *          0 <= KL <= M-1.
00036 *
00037 *  KU      (input) INTEGER
00038 *          The number of nonzero superdiagonals within the band of A.
00039 *          0 <= KU <= N-1.
00040 *
00041 *  D       (input) REAL array, dimension (min(M,N))
00042 *          The diagonal elements of the diagonal matrix D.
00043 *
00044 *  A       (output) COMPLEX array, dimension (LDA,N)
00045 *          The generated m by n matrix A.
00046 *
00047 *  LDA     (input) INTEGER
00048 *          The leading dimension of the array A.  LDA >= M.
00049 *
00050 *  ISEED   (input/output) INTEGER array, dimension (4)
00051 *          On entry, the seed of the random number generator; the array
00052 *          elements must be between 0 and 4095, and ISEED(4) must be
00053 *          odd.
00054 *          On exit, the seed is updated.
00055 *
00056 *  WORK    (workspace) COMPLEX array, dimension (M+N)
00057 *
00058 *  INFO    (output) INTEGER
00059 *          = 0: successful exit
00060 *          < 0: if INFO = -i, the i-th argument had an illegal value
00061 *
00062 *  =====================================================================
00063 *
00064 *     .. Parameters ..
00065       COMPLEX            ZERO, ONE
00066       PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ),
00067      $                   ONE = ( 1.0E+0, 0.0E+0 ) )
00068 *     ..
00069 *     .. Local Scalars ..
00070       INTEGER            I, J
00071       REAL               WN
00072       COMPLEX            TAU, WA, WB
00073 *     ..
00074 *     .. External Subroutines ..
00075       EXTERNAL           CGEMV, CGERC, CLACGV, CLARNV, CSCAL, XERBLA
00076 *     ..
00077 *     .. Intrinsic Functions ..
00078       INTRINSIC          ABS, MAX, MIN, REAL
00079 *     ..
00080 *     .. External Functions ..
00081       REAL               SCNRM2
00082       EXTERNAL           SCNRM2
00083 *     ..
00084 *     .. Executable Statements ..
00085 *
00086 *     Test the input arguments
00087 *
00088       INFO = 0
00089       IF( M.LT.0 ) THEN
00090          INFO = -1
00091       ELSE IF( N.LT.0 ) THEN
00092          INFO = -2
00093       ELSE IF( KL.LT.0 .OR. KL.GT.M-1 ) THEN
00094          INFO = -3
00095       ELSE IF( KU.LT.0 .OR. KU.GT.N-1 ) THEN
00096          INFO = -4
00097       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00098          INFO = -7
00099       END IF
00100       IF( INFO.LT.0 ) THEN
00101          CALL XERBLA( 'CLAGGE', -INFO )
00102          RETURN
00103       END IF
00104 *
00105 *     initialize A to diagonal matrix
00106 *
00107       DO 20 J = 1, N
00108          DO 10 I = 1, M
00109             A( I, J ) = ZERO
00110    10    CONTINUE
00111    20 CONTINUE
00112       DO 30 I = 1, MIN( M, N )
00113          A( I, I ) = D( I )
00114    30 CONTINUE
00115 *
00116 *     pre- and post-multiply A by random unitary matrices
00117 *
00118       DO 40 I = MIN( M, N ), 1, -1
00119          IF( I.LT.M ) THEN
00120 *
00121 *           generate random reflection
00122 *
00123             CALL CLARNV( 3, ISEED, M-I+1, WORK )
00124             WN = SCNRM2( M-I+1, WORK, 1 )
00125             WA = ( WN / ABS( WORK( 1 ) ) )*WORK( 1 )
00126             IF( WN.EQ.ZERO ) THEN
00127                TAU = ZERO
00128             ELSE
00129                WB = WORK( 1 ) + WA
00130                CALL CSCAL( M-I, ONE / WB, WORK( 2 ), 1 )
00131                WORK( 1 ) = ONE
00132                TAU = REAL( WB / WA )
00133             END IF
00134 *
00135 *           multiply A(i:m,i:n) by random reflection from the left
00136 *
00137             CALL CGEMV( 'Conjugate transpose', M-I+1, N-I+1, ONE,
00138      $                  A( I, I ), LDA, WORK, 1, ZERO, WORK( M+1 ), 1 )
00139             CALL CGERC( M-I+1, N-I+1, -TAU, WORK, 1, WORK( M+1 ), 1,
00140      $                  A( I, I ), LDA )
00141          END IF
00142          IF( I.LT.N ) THEN
00143 *
00144 *           generate random reflection
00145 *
00146             CALL CLARNV( 3, ISEED, N-I+1, WORK )
00147             WN = SCNRM2( N-I+1, WORK, 1 )
00148             WA = ( WN / ABS( WORK( 1 ) ) )*WORK( 1 )
00149             IF( WN.EQ.ZERO ) THEN
00150                TAU = ZERO
00151             ELSE
00152                WB = WORK( 1 ) + WA
00153                CALL CSCAL( N-I, ONE / WB, WORK( 2 ), 1 )
00154                WORK( 1 ) = ONE
00155                TAU = REAL( WB / WA )
00156             END IF
00157 *
00158 *           multiply A(i:m,i:n) by random reflection from the right
00159 *
00160             CALL CGEMV( 'No transpose', M-I+1, N-I+1, ONE, A( I, I ),
00161      $                  LDA, WORK, 1, ZERO, WORK( N+1 ), 1 )
00162             CALL CGERC( M-I+1, N-I+1, -TAU, WORK( N+1 ), 1, WORK, 1,
00163      $                  A( I, I ), LDA )
00164          END IF
00165    40 CONTINUE
00166 *
00167 *     Reduce number of subdiagonals to KL and number of superdiagonals
00168 *     to KU
00169 *
00170       DO 70 I = 1, MAX( M-1-KL, N-1-KU )
00171          IF( KL.LE.KU ) THEN
00172 *
00173 *           annihilate subdiagonal elements first (necessary if KL = 0)
00174 *
00175             IF( I.LE.MIN( M-1-KL, N ) ) THEN
00176 *
00177 *              generate reflection to annihilate A(kl+i+1:m,i)
00178 *
00179                WN = SCNRM2( M-KL-I+1, A( KL+I, I ), 1 )
00180                WA = ( WN / ABS( A( KL+I, I ) ) )*A( KL+I, I )
00181                IF( WN.EQ.ZERO ) THEN
00182                   TAU = ZERO
00183                ELSE
00184                   WB = A( KL+I, I ) + WA
00185                   CALL CSCAL( M-KL-I, ONE / WB, A( KL+I+1, I ), 1 )
00186                   A( KL+I, I ) = ONE
00187                   TAU = REAL( WB / WA )
00188                END IF
00189 *
00190 *              apply reflection to A(kl+i:m,i+1:n) from the left
00191 *
00192                CALL CGEMV( 'Conjugate transpose', M-KL-I+1, N-I, ONE,
00193      $                     A( KL+I, I+1 ), LDA, A( KL+I, I ), 1, ZERO,
00194      $                     WORK, 1 )
00195                CALL CGERC( M-KL-I+1, N-I, -TAU, A( KL+I, I ), 1, WORK,
00196      $                     1, A( KL+I, I+1 ), LDA )
00197                A( KL+I, I ) = -WA
00198             END IF
00199 *
00200             IF( I.LE.MIN( N-1-KU, M ) ) THEN
00201 *
00202 *              generate reflection to annihilate A(i,ku+i+1:n)
00203 *
00204                WN = SCNRM2( N-KU-I+1, A( I, KU+I ), LDA )
00205                WA = ( WN / ABS( A( I, KU+I ) ) )*A( I, KU+I )
00206                IF( WN.EQ.ZERO ) THEN
00207                   TAU = ZERO
00208                ELSE
00209                   WB = A( I, KU+I ) + WA
00210                   CALL CSCAL( N-KU-I, ONE / WB, A( I, KU+I+1 ), LDA )
00211                   A( I, KU+I ) = ONE
00212                   TAU = REAL( WB / WA )
00213                END IF
00214 *
00215 *              apply reflection to A(i+1:m,ku+i:n) from the right
00216 *
00217                CALL CLACGV( N-KU-I+1, A( I, KU+I ), LDA )
00218                CALL CGEMV( 'No transpose', M-I, N-KU-I+1, ONE,
00219      $                     A( I+1, KU+I ), LDA, A( I, KU+I ), LDA, ZERO,
00220      $                     WORK, 1 )
00221                CALL CGERC( M-I, N-KU-I+1, -TAU, WORK, 1, A( I, KU+I ),
00222      $                     LDA, A( I+1, KU+I ), LDA )
00223                A( I, KU+I ) = -WA
00224             END IF
00225          ELSE
00226 *
00227 *           annihilate superdiagonal elements first (necessary if
00228 *           KU = 0)
00229 *
00230             IF( I.LE.MIN( N-1-KU, M ) ) THEN
00231 *
00232 *              generate reflection to annihilate A(i,ku+i+1:n)
00233 *
00234                WN = SCNRM2( N-KU-I+1, A( I, KU+I ), LDA )
00235                WA = ( WN / ABS( A( I, KU+I ) ) )*A( I, KU+I )
00236                IF( WN.EQ.ZERO ) THEN
00237                   TAU = ZERO
00238                ELSE
00239                   WB = A( I, KU+I ) + WA
00240                   CALL CSCAL( N-KU-I, ONE / WB, A( I, KU+I+1 ), LDA )
00241                   A( I, KU+I ) = ONE
00242                   TAU = REAL( WB / WA )
00243                END IF
00244 *
00245 *              apply reflection to A(i+1:m,ku+i:n) from the right
00246 *
00247                CALL CLACGV( N-KU-I+1, A( I, KU+I ), LDA )
00248                CALL CGEMV( 'No transpose', M-I, N-KU-I+1, ONE,
00249      $                     A( I+1, KU+I ), LDA, A( I, KU+I ), LDA, ZERO,
00250      $                     WORK, 1 )
00251                CALL CGERC( M-I, N-KU-I+1, -TAU, WORK, 1, A( I, KU+I ),
00252      $                     LDA, A( I+1, KU+I ), LDA )
00253                A( I, KU+I ) = -WA
00254             END IF
00255 *
00256             IF( I.LE.MIN( M-1-KL, N ) ) THEN
00257 *
00258 *              generate reflection to annihilate A(kl+i+1:m,i)
00259 *
00260                WN = SCNRM2( M-KL-I+1, A( KL+I, I ), 1 )
00261                WA = ( WN / ABS( A( KL+I, I ) ) )*A( KL+I, I )
00262                IF( WN.EQ.ZERO ) THEN
00263                   TAU = ZERO
00264                ELSE
00265                   WB = A( KL+I, I ) + WA
00266                   CALL CSCAL( M-KL-I, ONE / WB, A( KL+I+1, I ), 1 )
00267                   A( KL+I, I ) = ONE
00268                   TAU = REAL( WB / WA )
00269                END IF
00270 *
00271 *              apply reflection to A(kl+i:m,i+1:n) from the left
00272 *
00273                CALL CGEMV( 'Conjugate transpose', M-KL-I+1, N-I, ONE,
00274      $                     A( KL+I, I+1 ), LDA, A( KL+I, I ), 1, ZERO,
00275      $                     WORK, 1 )
00276                CALL CGERC( M-KL-I+1, N-I, -TAU, A( KL+I, I ), 1, WORK,
00277      $                     1, A( KL+I, I+1 ), LDA )
00278                A( KL+I, I ) = -WA
00279             END IF
00280          END IF
00281 *
00282          DO 50 J = KL + I + 1, M
00283             A( J, I ) = ZERO
00284    50    CONTINUE
00285 *
00286          DO 60 J = KU + I + 1, N
00287             A( I, J ) = ZERO
00288    60    CONTINUE
00289    70 CONTINUE
00290       RETURN
00291 *
00292 *     End of CLAGGE
00293 *
00294       END
 All Files Functions