1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
      SUBROUTINE ZLARORSIDEINITMNALDAISEEDXINFO )
*
*  -- LAPACK auxiliary test routine (version 3.1) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     June 2010
*
*     .. Scalar Arguments ..
      CHARACTER          INITSIDE
      INTEGER            INFOLDAMN
*     ..
*     .. Array Arguments ..
      INTEGER            ISEED4 )
      COMPLEX*16         ALDA* ), X* )
*     ..
*
*  Purpose
*  =======
*
*     ZLAROR pre- or post-multiplies an M by N matrix A by a random
*     unitary matrix U, overwriting A. A may optionally be
*     initialized to the identity matrix before multiplying by U.
*     U is generated using the method of G.W. Stewart
*     ( SIAM J. Numer. Anal. 17, 1980, pp. 403-409 ).
*     (BLAS-2 version)
*
*  Arguments
*  =========
*
*  SIDE     (input) CHARACTER*1
*           SIDE specifies whether A is multiplied on the left or right
*           by U.
*       SIDE = 'L'   Multiply A on the left (premultiply) by U
*       SIDE = 'R'   Multiply A on the right (postmultiply) by U*
*       SIDE = 'C'   Multiply A on the left by U and the right by U*
*       SIDE = 'T'   Multiply A on the left by U and the right by U'
*           Not modified.
*
*  INIT     (input) CHARACTER*1
*           INIT specifies whether or not A should be initialized to
*           the identity matrix.
*              INIT = 'I'   Initialize A to (a section of) the
*                           identity matrix before applying U.
*              INIT = 'N'   No initialization.  Apply U to the
*                           input matrix A.
*
*           INIT = 'I' may be used to generate square (i.e., unitary)
*           or rectangular orthogonal matrices (orthogonality being
*           in the sense of ZDOTC):
*
*           For square matrices, M=N, and SIDE many be either 'L' or
*           'R'; the rows will be orthogonal to each other, as will the
*           columns.
*           For rectangular matrices where M < N, SIDE = 'R' will
*           produce a dense matrix whose rows will be orthogonal and
*           whose columns will not, while SIDE = 'L' will produce a
*           matrix whose rows will be orthogonal, and whose first M
*           columns will be orthogonal, the remaining columns being
*           zero.
*           For matrices where M > N, just use the previous
*           explanation, interchanging 'L' and 'R' and "rows" and
*           "columns".
*
*           Not modified.
*
*  M        (input) INTEGER
*           Number of rows of A. Not modified.
*
*  N        (input) INTEGER
*           Number of columns of A. Not modified.
*
*  A        COMPLEX*16 array, dimension ( LDA, N )
*           Input and output array. Overwritten by U A ( if SIDE = 'L' )
*           or by A U ( if SIDE = 'R' )
*           or by U A U* ( if SIDE = 'C')
*           or by U A U' ( if SIDE = 'T') on exit.
*
*  LDA      (input) INTEGER
*           Leading dimension of A. Must be at least MAX ( 1, M ).
*           Not modified.
*
*  ISEED    (input/output) INTEGER array, dimension ( 4 )
*           On entry ISEED specifies the seed of the random number
*           generator. The array elements should be between 0 and 4095;
*           if not they will be reduced mod 4096.  Also, ISEED(4) must
*           be odd.  The random number generator uses a linear
*           congruential sequence limited to small integers, and so
*           should produce machine independent random numbers. The
*           values of ISEED are changed on exit, and can be used in the
*           next call to ZLAROR to continue the same random number
*           sequence.
*           Modified.
*
*  X       (workspace) COMPLEX*16 array, dimension ( 3*MAX( M, N ) )
*           Workspace. Of length:
*               2*M + N if SIDE = 'L',
*               2*N + M if SIDE = 'R',
*               3*N     if SIDE = 'C' or 'T'.
*           Modified.
*
*  INFO    (output) INTEGER
*           An error flag.  It is set to:
*            0  if no error.
*            1  if ZLARND returned a bad random number (installation
*               problem)
*           -1  if SIDE is not L, R, C, or T.
*           -3  if M is negative.
*           -4  if N is negative or if SIDE is C or T and N is not equal
*               to M.
*           -6  if LDA is less than M.
*
*  =====================================================================
*
*     .. Parameters ..
      DOUBLE PRECISION   ZEROONETOOSML
      PARAMETER          ( ZERO = 0.0D+0ONE = 1.0D+0,
     $                   TOOSML = 1.0D-20 )
      COMPLEX*16         CZEROCONE
      PARAMETER          ( CZERO = ( 0.0D+00.0D+0 ),
     $                   CONE = ( 1.0D+00.0D+0 ) )
*     ..
*     .. Local Scalars ..
      INTEGER            IROWITYPEIXFRMJJCOLKBEGNXFRM
      DOUBLE PRECISION   FACTORXABSXNORM
      COMPLEX*16         CSIGNXNORMS
*     ..
*     .. External Functions ..
      LOGICAL            LSAME
      DOUBLE PRECISION   DZNRM2
      COMPLEX*16         ZLARND
      EXTERNAL           LSAMEDZNRM2ZLARND
*     ..
*     .. External Subroutines ..
      EXTERNAL           XERBLAZGEMVZGERCZLACGVZLASETZSCAL
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          ABSDCMPLXDCONJG
*     ..
*     .. Executable Statements ..
*
      IFN.EQ.0 .OR. M.EQ.0 )
     $   RETURN
*
      ITYPE = 0
      IFLSAMESIDE'L' ) ) THEN
         ITYPE = 1
      ELSE IFLSAMESIDE'R' ) ) THEN
         ITYPE = 2
      ELSE IFLSAMESIDE'C' ) ) THEN
         ITYPE = 3
      ELSE IFLSAMESIDE'T' ) ) THEN
         ITYPE = 4
      END IF
*
*     Check for argument errors.
*
      INFO = 0
      IFITYPE.EQ.0 ) THEN
         INFO = -1
      ELSE IFM.LT.0 ) THEN
         INFO = -3
      ELSE IFN.LT.0 .OR. ( ITYPE.EQ.3 .AND. N.NE.M ) ) THEN
         INFO = -4
      ELSE IFLDA.LT.M ) THEN
         INFO = -6
      END IF
      IFINFO.NE.0 ) THEN
         CALL XERBLA'ZLAROR'-INFO )
         RETURN
      END IF
*
      IFITYPE.EQ.1 ) THEN
         NXFRM = M
      ELSE
         NXFRM = N
      END IF
*
*     Initialize A to the identity matrix if desired
*
      IFLSAMEINIT'I' ) )
     $   CALL ZLASET'Full'MNCZEROCONEALDA )
*
*     If no rotation possible, still multiply by
*     a random complex number from the circle |x| = 1
*
*      2)      Compute Rotation by computing Householder
*              Transformations H(2), H(3), ..., H(n).  Note that the
*              order in which they are computed is irrelevant.
*
      DO 10 J = 1NXFRM
         XJ ) = CZERO
   10 CONTINUE
*
      DO 30 IXFRM = 2NXFRM
         KBEG = NXFRM - IXFRM + 1
*
*        Generate independent normal( 0, 1 ) random numbers
*
         DO 20 J = KBEGNXFRM
            XJ ) = ZLARND3ISEED )
   20    CONTINUE
*
*        Generate a Householder transformation from the random vector X
*
         XNORM = DZNRM2IXFRMXKBEG ), 1 )
         XABS = ABSXKBEG ) )
         IFXABS.NE.CZERO ) THEN
            CSIGN = XKBEG ) / XABS
         ELSE
            CSIGN = CONE
         END IF
         XNORMS = CSIGN*XNORM
         XNXFRM+KBEG ) = -CSIGN
         FACTOR = XNORM*XNORM+XABS )
         IFABSFACTOR ).LT.TOOSML ) THEN
            INFO = 1
            CALL XERBLA'ZLAROR'-INFO )
            RETURN
         ELSE
            FACTOR = ONE / FACTOR
         END IF
         XKBEG ) = XKBEG ) + XNORMS
*
*        Apply Householder transformation to A
*
         IFITYPE.EQ.1 .OR. ITYPE.EQ.3 .OR. ITYPE.EQ.4 ) THEN
*
*           Apply H(k) on the left of A
*
            CALL ZGEMV'C'IXFRMNCONEAKBEG1 ), LDA,
     $                  XKBEG ), 1CZEROX2*NXFRM+1 ), 1 )
            CALL ZGERCIXFRMN-DCMPLXFACTOR ), XKBEG ), 1,
     $                  X2*NXFRM+1 ), 1AKBEG1 ), LDA )
*
         END IF
*
         IFITYPE.GE.2 .AND. ITYPE.LE.4 ) THEN
*
*           Apply H(k)* (or H(k)') on the right of A
*
            IFITYPE.EQ.4 ) THEN
               CALL ZLACGVIXFRMXKBEG ), 1 )
            END IF
*
            CALL ZGEMV'N'MIXFRMCONEA1KBEG ), LDA,
     $                  XKBEG ), 1CZEROX2*NXFRM+1 ), 1 )
            CALL ZGERCMIXFRM-DCMPLXFACTOR ), X2*NXFRM+1 ), 1,
     $                  XKBEG ), 1A1KBEG ), LDA )
*
         END IF
   30 CONTINUE
*
      X1 ) = ZLARND3ISEED )
      XABS = ABSX1 ) )
      IFXABS.NE.ZERO ) THEN
         CSIGN = X1 ) / XABS
      ELSE
         CSIGN = CONE
      END IF
      X2*NXFRM ) = CSIGN
*
*     Scale the matrix A by D.
*
      IFITYPE.EQ.1 .OR. ITYPE.EQ.3 .OR. ITYPE.EQ.4 ) THEN
         DO 40 IROW = 1M
            CALL ZSCALNDCONJGXNXFRM+IROW ) ), AIROW1 ),
     $                  LDA )
   40    CONTINUE
      END IF
*
      IFITYPE.EQ.2 .OR. ITYPE.EQ.3 ) THEN
         DO 50 JCOL = 1N
            CALL ZSCALMXNXFRM+JCOL ), A1JCOL ), 1 )
   50    CONTINUE
      END IF
*
      IFITYPE.EQ.4 ) THEN
         DO 60 JCOL = 1N
            CALL ZSCALMDCONJGXNXFRM+JCOL ) ), A1JCOL ), 1 )
   60    CONTINUE
      END IF
      RETURN
*
*     End of ZLAROR
*
      END