LAPACK 3.3.0

zlatm2.f

Go to the documentation of this file.
00001       DOUBLE COMPLEX   FUNCTION ZLATM2( M, N, I, J, KL, KU, IDIST,
00002      $                 ISEED, D, IGRADE, DL, DR, IPVTNG, IWORK, SPARSE )
00003 *
00004 *  -- LAPACK auxiliary test routine (version 3.1) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     June 2010
00007 *
00008 *     .. Scalar Arguments ..
00009 *
00010       INTEGER            I, IDIST, IGRADE, IPVTNG, J, KL, KU, M, N
00011       DOUBLE PRECISION   SPARSE
00012 *     ..
00013 *
00014 *     .. Array Arguments ..
00015 *
00016       INTEGER            ISEED( 4 ), IWORK( * )
00017       COMPLEX*16         D( * ), DL( * ), DR( * )
00018 *     ..
00019 *
00020 *  Purpose
00021 *  =======
00022 *
00023 *     ZLATM2 returns the (I,J) entry of a random matrix of dimension
00024 *     (M, N) described by the other paramters. It is called by the
00025 *     ZLATMR routine in order to build random test matrices. No error
00026 *     checking on parameters is done, because this routine is called in
00027 *     a tight loop by ZLATMR which has already checked the parameters.
00028 *
00029 *     Use of ZLATM2 differs from CLATM3 in the order in which the random
00030 *     number generator is called to fill in random matrix entries.
00031 *     With ZLATM2, the generator is called to fill in the pivoted matrix
00032 *     columnwise. With ZLATM3, the generator is called to fill in the
00033 *     matrix columnwise, after which it is pivoted. Thus, ZLATM3 can
00034 *     be used to construct random matrices which differ only in their
00035 *     order of rows and/or columns. ZLATM2 is used to construct band
00036 *     matrices while avoiding calling the random number generator for
00037 *     entries outside the band (and therefore generating random numbers
00038 *
00039 *     The matrix whose (I,J) entry is returned is constructed as
00040 *     follows (this routine only computes one entry):
00041 *
00042 *       If I is outside (1..M) or J is outside (1..N), return zero
00043 *          (this is convenient for generating matrices in band format).
00044 *
00045 *       Generate a matrix A with random entries of distribution IDIST.
00046 *
00047 *       Set the diagonal to D.
00048 *
00049 *       Grade the matrix, if desired, from the left (by DL) and/or
00050 *          from the right (by DR or DL) as specified by IGRADE.
00051 *
00052 *       Permute, if desired, the rows and/or columns as specified by
00053 *          IPVTNG and IWORK.
00054 *
00055 *       Band the matrix to have lower bandwidth KL and upper
00056 *          bandwidth KU.
00057 *
00058 *       Set random entries to zero as specified by SPARSE.
00059 *
00060 *  Arguments
00061 *  =========
00062 *
00063 *  M        (input) INTEGER
00064 *           Number of rows of matrix. Not modified.
00065 *
00066 *  N        (input) INTEGER
00067 *           Number of columns of matrix. Not modified.
00068 *
00069 *  I        (input) INTEGER
00070 *           Row of entry to be returned. Not modified.
00071 *
00072 *  J        (input) INTEGER
00073 *           Column of entry to be returned. Not modified.
00074 *
00075 *  KL       (input) INTEGER
00076 *           Lower bandwidth. Not modified.
00077 *
00078 *  KU       (input) INTEGER
00079 *           Upper bandwidth. Not modified.
00080 *
00081 *  IDIST    (input) INTEGER
00082 *           On entry, IDIST specifies the type of distribution to be
00083 *           used to generate a random matrix .
00084 *           1 => real and imaginary parts each UNIFORM( 0, 1 )
00085 *           2 => real and imaginary parts each UNIFORM( -1, 1 )
00086 *           3 => real and imaginary parts each NORMAL( 0, 1 )
00087 *           4 => complex number uniform in DISK( 0 , 1 )
00088 *           Not modified.
00089 *
00090 *  ISEED    (input/output) INTEGER array of dimension ( 4 )
00091 *           Seed for random number generator.
00092 *           Changed on exit.
00093 *
00094 *  D        (input) COMPLEX*16 array of dimension ( MIN( I , J ) )
00095 *           Diagonal entries of matrix. Not modified.
00096 *
00097 *  IGRADE   (input) INTEGER
00098 *           Specifies grading of matrix as follows:
00099 *           0  => no grading
00100 *           1  => matrix premultiplied by diag( DL )
00101 *           2  => matrix postmultiplied by diag( DR )
00102 *           3  => matrix premultiplied by diag( DL ) and
00103 *                         postmultiplied by diag( DR )
00104 *           4  => matrix premultiplied by diag( DL ) and
00105 *                         postmultiplied by inv( diag( DL ) )
00106 *           5  => matrix premultiplied by diag( DL ) and
00107 *                         postmultiplied by diag( CONJG(DL) )
00108 *           6  => matrix premultiplied by diag( DL ) and
00109 *                         postmultiplied by diag( DL )
00110 *           Not modified.
00111 *
00112 *  DL       (input) COMPLEX*16 array ( I or J, as appropriate )
00113 *           Left scale factors for grading matrix.  Not modified.
00114 *
00115 *  DR       (input) COMPLEX*16 array ( I or J, as appropriate )
00116 *           Right scale factors for grading matrix.  Not modified.
00117 *
00118 *  IPVTNG   (input) INTEGER
00119 *           On entry specifies pivoting permutations as follows:
00120 *           0 => none.
00121 *           1 => row pivoting.
00122 *           2 => column pivoting.
00123 *           3 => full pivoting, i.e., on both sides.
00124 *           Not modified.
00125 *
00126 *  IWORK    (workspace) INTEGER array ( I or J, as appropriate )
00127 *           This array specifies the permutation used. The
00128 *           row (or column) in position K was originally in
00129 *           position IWORK( K ).
00130 *           This differs from IWORK for ZLATM3. Not modified.
00131 *
00132 *  SPARSE   (input) DOUBLE PRECISION between 0. and 1.
00133 *           On entry specifies the sparsity of the matrix
00134 *           if sparse matix is to be generated.
00135 *           SPARSE should lie between 0 and 1.
00136 *           A uniform ( 0, 1 ) random number x is generated and
00137 *           compared to SPARSE; if x is larger the matrix entry
00138 *           is unchanged and if x is smaller the entry is set
00139 *           to zero. Thus on the average a fraction SPARSE of the
00140 *           entries will be set to zero.
00141 *           Not modified.
00142 *
00143 *  =====================================================================
00144 *
00145 *     .. Parameters ..
00146 *
00147       COMPLEX*16         CZERO
00148       PARAMETER          ( CZERO = ( 0.0D0, 0.0D0 ) )
00149       DOUBLE PRECISION   ZERO
00150       PARAMETER          ( ZERO = 0.0D0 )
00151 *     ..
00152 *
00153 *     .. Local Scalars ..
00154 *
00155       INTEGER            ISUB, JSUB
00156       COMPLEX*16         CTEMP
00157 *     ..
00158 *
00159 *     .. External Functions ..
00160 *
00161       DOUBLE PRECISION   DLARAN
00162       COMPLEX*16         ZLARND
00163       EXTERNAL           DLARAN, ZLARND
00164 *     ..
00165 *
00166 *     .. Intrinsic Functions ..
00167 *
00168       INTRINSIC          DCONJG
00169 *     ..
00170 *
00171 *-----------------------------------------------------------------------
00172 *
00173 *     .. Executable Statements ..
00174 *
00175 *
00176 *     Check for I and J in range
00177 *
00178       IF( I.LT.1 .OR. I.GT.M .OR. J.LT.1 .OR. J.GT.N ) THEN
00179          ZLATM2 = CZERO
00180          RETURN
00181       END IF
00182 *
00183 *     Check for banding
00184 *
00185       IF( J.GT.I+KU .OR. J.LT.I-KL ) THEN
00186          ZLATM2 = CZERO
00187          RETURN
00188       END IF
00189 *
00190 *     Check for sparsity
00191 *
00192       IF( SPARSE.GT.ZERO ) THEN
00193          IF( DLARAN( ISEED ).LT.SPARSE ) THEN
00194             ZLATM2 = CZERO
00195             RETURN
00196          END IF
00197       END IF
00198 *
00199 *     Compute subscripts depending on IPVTNG
00200 *
00201       IF( IPVTNG.EQ.0 ) THEN
00202          ISUB = I
00203          JSUB = J
00204       ELSE IF( IPVTNG.EQ.1 ) THEN
00205          ISUB = IWORK( I )
00206          JSUB = J
00207       ELSE IF( IPVTNG.EQ.2 ) THEN
00208          ISUB = I
00209          JSUB = IWORK( J )
00210       ELSE IF( IPVTNG.EQ.3 ) THEN
00211          ISUB = IWORK( I )
00212          JSUB = IWORK( J )
00213       END IF
00214 *
00215 *     Compute entry and grade it according to IGRADE
00216 *
00217       IF( ISUB.EQ.JSUB ) THEN
00218          CTEMP = D( ISUB )
00219       ELSE
00220          CTEMP = ZLARND( IDIST, ISEED )
00221       END IF
00222       IF( IGRADE.EQ.1 ) THEN
00223          CTEMP = CTEMP*DL( ISUB )
00224       ELSE IF( IGRADE.EQ.2 ) THEN
00225          CTEMP = CTEMP*DR( JSUB )
00226       ELSE IF( IGRADE.EQ.3 ) THEN
00227          CTEMP = CTEMP*DL( ISUB )*DR( JSUB )
00228       ELSE IF( IGRADE.EQ.4 .AND. ISUB.NE.JSUB ) THEN
00229          CTEMP = CTEMP*DL( ISUB ) / DL( JSUB )
00230       ELSE IF( IGRADE.EQ.5 ) THEN
00231          CTEMP = CTEMP*DL( ISUB )*DCONJG( DL( JSUB ) )
00232       ELSE IF( IGRADE.EQ.6 ) THEN
00233          CTEMP = CTEMP*DL( ISUB )*DL( JSUB )
00234       END IF
00235       ZLATM2 = CTEMP
00236       RETURN
00237 *
00238 *     End of ZLATM2
00239 *
00240       END
 All Files Functions