![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DLATM2 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 * Definition: 00009 * =========== 00010 * 00011 * DOUBLE PRECISION FUNCTION DLATM2( M, N, I, J, KL, KU, IDIST, 00012 * ISEED, D, IGRADE, DL, DR, IPVTNG, IWORK, SPARSE ) 00013 * 00014 * .. Scalar Arguments .. 00015 * 00016 * INTEGER I, IDIST, IGRADE, IPVTNG, J, KL, KU, M, N 00017 * DOUBLE PRECISION SPARSE 00018 * .. 00019 * 00020 * .. Array Arguments .. 00021 * 00022 * INTEGER ISEED( 4 ), IWORK( * ) 00023 * DOUBLE PRECISION D( * ), DL( * ), DR( * ) 00024 * .. 00025 * 00026 * 00027 *> \par Purpose: 00028 * ============= 00029 *> 00030 *> \verbatim 00031 *> 00032 *> DLATM2 returns the (I,J) entry of a random matrix of dimension 00033 *> (M, N) described by the other paramters. It is called by the 00034 *> DLATMR routine in order to build random test matrices. No error 00035 *> checking on parameters is done, because this routine is called in 00036 *> a tight loop by DLATMR which has already checked the parameters. 00037 *> 00038 *> Use of DLATM2 differs from SLATM3 in the order in which the random 00039 *> number generator is called to fill in random matrix entries. 00040 *> With DLATM2, the generator is called to fill in the pivoted matrix 00041 *> columnwise. With DLATM3, the generator is called to fill in the 00042 *> matrix columnwise, after which it is pivoted. Thus, DLATM3 can 00043 *> be used to construct random matrices which differ only in their 00044 *> order of rows and/or columns. DLATM2 is used to construct band 00045 *> matrices while avoiding calling the random number generator for 00046 *> entries outside the band (and therefore generating random numbers 00047 *> 00048 *> The matrix whose (I,J) entry is returned is constructed as 00049 *> follows (this routine only computes one entry): 00050 *> 00051 *> If I is outside (1..M) or J is outside (1..N), return zero 00052 *> (this is convenient for generating matrices in band format). 00053 *> 00054 *> Generate a matrix A with random entries of distribution IDIST. 00055 *> 00056 *> Set the diagonal to D. 00057 *> 00058 *> Grade the matrix, if desired, from the left (by DL) and/or 00059 *> from the right (by DR or DL) as specified by IGRADE. 00060 *> 00061 *> Permute, if desired, the rows and/or columns as specified by 00062 *> IPVTNG and IWORK. 00063 *> 00064 *> Band the matrix to have lower bandwidth KL and upper 00065 *> bandwidth KU. 00066 *> 00067 *> Set random entries to zero as specified by SPARSE. 00068 *> \endverbatim 00069 * 00070 * Arguments: 00071 * ========== 00072 * 00073 *> \param[in] M 00074 *> \verbatim 00075 *> M is INTEGER 00076 *> Number of rows of matrix. Not modified. 00077 *> \endverbatim 00078 *> 00079 *> \param[in] N 00080 *> \verbatim 00081 *> N is INTEGER 00082 *> Number of columns of matrix. Not modified. 00083 *> \endverbatim 00084 *> 00085 *> \param[in] I 00086 *> \verbatim 00087 *> I is INTEGER 00088 *> Row of entry to be returned. Not modified. 00089 *> \endverbatim 00090 *> 00091 *> \param[in] J 00092 *> \verbatim 00093 *> J is INTEGER 00094 *> Column of entry to be returned. Not modified. 00095 *> \endverbatim 00096 *> 00097 *> \param[in] KL 00098 *> \verbatim 00099 *> KL is INTEGER 00100 *> Lower bandwidth. Not modified. 00101 *> \endverbatim 00102 *> 00103 *> \param[in] KU 00104 *> \verbatim 00105 *> KU is INTEGER 00106 *> Upper bandwidth. Not modified. 00107 *> \endverbatim 00108 *> 00109 *> \param[in] IDIST 00110 *> \verbatim 00111 *> IDIST is INTEGER 00112 *> On entry, IDIST specifies the type of distribution to be 00113 *> used to generate a random matrix . 00114 *> 1 => UNIFORM( 0, 1 ) 00115 *> 2 => UNIFORM( -1, 1 ) 00116 *> 3 => NORMAL( 0, 1 ) 00117 *> Not modified. 00118 *> \endverbatim 00119 *> 00120 *> \param[in,out] ISEED 00121 *> \verbatim 00122 *> ISEED is INTEGER array of dimension ( 4 ) 00123 *> Seed for random number generator. 00124 *> Changed on exit. 00125 *> \endverbatim 00126 *> 00127 *> \param[in] D 00128 *> \verbatim 00129 *> D is DOUBLE PRECISION array of dimension ( MIN( I , J ) ) 00130 *> Diagonal entries of matrix. Not modified. 00131 *> \endverbatim 00132 *> 00133 *> \param[in] IGRADE 00134 *> \verbatim 00135 *> IGRADE is INTEGER 00136 *> Specifies grading of matrix as follows: 00137 *> 0 => no grading 00138 *> 1 => matrix premultiplied by diag( DL ) 00139 *> 2 => matrix postmultiplied by diag( DR ) 00140 *> 3 => matrix premultiplied by diag( DL ) and 00141 *> postmultiplied by diag( DR ) 00142 *> 4 => matrix premultiplied by diag( DL ) and 00143 *> postmultiplied by inv( diag( DL ) ) 00144 *> 5 => matrix premultiplied by diag( DL ) and 00145 *> postmultiplied by diag( DL ) 00146 *> Not modified. 00147 *> \endverbatim 00148 *> 00149 *> \param[in] DL 00150 *> \verbatim 00151 *> DL is DOUBLE PRECISION array ( I or J, as appropriate ) 00152 *> Left scale factors for grading matrix. Not modified. 00153 *> \endverbatim 00154 *> 00155 *> \param[in] DR 00156 *> \verbatim 00157 *> DR is DOUBLE PRECISION array ( I or J, as appropriate ) 00158 *> Right scale factors for grading matrix. Not modified. 00159 *> \endverbatim 00160 *> 00161 *> \param[in] IPVTNG 00162 *> \verbatim 00163 *> IPVTNG is INTEGER 00164 *> On entry specifies pivoting permutations as follows: 00165 *> 0 => none. 00166 *> 1 => row pivoting. 00167 *> 2 => column pivoting. 00168 *> 3 => full pivoting, i.e., on both sides. 00169 *> Not modified. 00170 *> \endverbatim 00171 *> 00172 *> \param[out] IWORK 00173 *> \verbatim 00174 *> IWORK is INTEGER array ( I or J, as appropriate ) 00175 *> This array specifies the permutation used. The 00176 *> row (or column) in position K was originally in 00177 *> position IWORK( K ). 00178 *> This differs from IWORK for DLATM3. Not modified. 00179 *> \endverbatim 00180 *> 00181 *> \param[in] SPARSE 00182 *> \verbatim 00183 *> SPARSE is DOUBLE PRECISION between 0. and 1. 00184 *> On entry specifies the sparsity of the matrix 00185 *> if sparse matix is to be generated. 00186 *> SPARSE should lie between 0 and 1. 00187 *> A uniform ( 0, 1 ) random number x is generated and 00188 *> compared to SPARSE; if x is larger the matrix entry 00189 *> is unchanged and if x is smaller the entry is set 00190 *> to zero. Thus on the average a fraction SPARSE of the 00191 *> entries will be set to zero. 00192 *> Not modified. 00193 *> \endverbatim 00194 * 00195 * Authors: 00196 * ======== 00197 * 00198 *> \author Univ. of Tennessee 00199 *> \author Univ. of California Berkeley 00200 *> \author Univ. of Colorado Denver 00201 *> \author NAG Ltd. 00202 * 00203 *> \date November 2011 00204 * 00205 *> \ingroup double_matgen 00206 * 00207 * ===================================================================== 00208 DOUBLE PRECISION FUNCTION DLATM2( M, N, I, J, KL, KU, IDIST, 00209 $ ISEED, D, IGRADE, DL, DR, IPVTNG, IWORK, SPARSE ) 00210 * 00211 * -- LAPACK auxiliary routine (version 3.4.0) -- 00212 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00213 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00214 * November 2011 00215 * 00216 * .. Scalar Arguments .. 00217 * 00218 INTEGER I, IDIST, IGRADE, IPVTNG, J, KL, KU, M, N 00219 DOUBLE PRECISION SPARSE 00220 * .. 00221 * 00222 * .. Array Arguments .. 00223 * 00224 INTEGER ISEED( 4 ), IWORK( * ) 00225 DOUBLE PRECISION D( * ), DL( * ), DR( * ) 00226 * .. 00227 * 00228 * ===================================================================== 00229 * 00230 * .. Parameters .. 00231 * 00232 DOUBLE PRECISION ZERO 00233 PARAMETER ( ZERO = 0.0D0 ) 00234 * .. 00235 * 00236 * .. Local Scalars .. 00237 * 00238 INTEGER ISUB, JSUB 00239 DOUBLE PRECISION TEMP 00240 * .. 00241 * 00242 * .. External Functions .. 00243 * 00244 DOUBLE PRECISION DLARAN, DLARND 00245 EXTERNAL DLARAN, DLARND 00246 * .. 00247 * 00248 *----------------------------------------------------------------------- 00249 * 00250 * .. Executable Statements .. 00251 * 00252 * 00253 * Check for I and J in range 00254 * 00255 IF( I.LT.1 .OR. I.GT.M .OR. J.LT.1 .OR. J.GT.N ) THEN 00256 DLATM2 = ZERO 00257 RETURN 00258 END IF 00259 * 00260 * Check for banding 00261 * 00262 IF( J.GT.I+KU .OR. J.LT.I-KL ) THEN 00263 DLATM2 = ZERO 00264 RETURN 00265 END IF 00266 * 00267 * Check for sparsity 00268 * 00269 IF( SPARSE.GT.ZERO ) THEN 00270 IF( DLARAN( ISEED ).LT.SPARSE ) THEN 00271 DLATM2 = ZERO 00272 RETURN 00273 END IF 00274 END IF 00275 * 00276 * Compute subscripts depending on IPVTNG 00277 * 00278 IF( IPVTNG.EQ.0 ) THEN 00279 ISUB = I 00280 JSUB = J 00281 ELSE IF( IPVTNG.EQ.1 ) THEN 00282 ISUB = IWORK( I ) 00283 JSUB = J 00284 ELSE IF( IPVTNG.EQ.2 ) THEN 00285 ISUB = I 00286 JSUB = IWORK( J ) 00287 ELSE IF( IPVTNG.EQ.3 ) THEN 00288 ISUB = IWORK( I ) 00289 JSUB = IWORK( J ) 00290 END IF 00291 * 00292 * Compute entry and grade it according to IGRADE 00293 * 00294 IF( ISUB.EQ.JSUB ) THEN 00295 TEMP = D( ISUB ) 00296 ELSE 00297 TEMP = DLARND( IDIST, ISEED ) 00298 END IF 00299 IF( IGRADE.EQ.1 ) THEN 00300 TEMP = TEMP*DL( ISUB ) 00301 ELSE IF( IGRADE.EQ.2 ) THEN 00302 TEMP = TEMP*DR( JSUB ) 00303 ELSE IF( IGRADE.EQ.3 ) THEN 00304 TEMP = TEMP*DL( ISUB )*DR( JSUB ) 00305 ELSE IF( IGRADE.EQ.4 .AND. ISUB.NE.JSUB ) THEN 00306 TEMP = TEMP*DL( ISUB ) / DL( JSUB ) 00307 ELSE IF( IGRADE.EQ.5 ) THEN 00308 TEMP = TEMP*DL( ISUB )*DL( JSUB ) 00309 END IF 00310 DLATM2 = TEMP 00311 RETURN 00312 * 00313 * End of DLATM2 00314 * 00315 END