![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SLATM1 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 * Definition: 00009 * =========== 00010 * 00011 * SUBROUTINE SLATM1( MODE, COND, IRSIGN, IDIST, ISEED, D, N, INFO ) 00012 * 00013 * .. Scalar Arguments .. 00014 * INTEGER IDIST, INFO, IRSIGN, MODE, N 00015 * REAL COND 00016 * .. 00017 * .. Array Arguments .. 00018 * INTEGER ISEED( 4 ) 00019 * REAL D( * ) 00020 * .. 00021 * 00022 * 00023 *> \par Purpose: 00024 * ============= 00025 *> 00026 *> \verbatim 00027 *> 00028 *> SLATM1 computes the entries of D(1..N) as specified by 00029 *> MODE, COND and IRSIGN. IDIST and ISEED determine the generation 00030 *> of random numbers. SLATM1 is called by SLATMR to generate 00031 *> random test matrices for LAPACK programs. 00032 *> \endverbatim 00033 * 00034 * Arguments: 00035 * ========== 00036 * 00037 *> \param[in] MODE 00038 *> \verbatim 00039 *> MODE is INTEGER 00040 *> On entry describes how D is to be computed: 00041 *> MODE = 0 means do not change D. 00042 *> MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND 00043 *> MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND 00044 *> MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) 00045 *> MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) 00046 *> MODE = 5 sets D to random numbers in the range 00047 *> ( 1/COND , 1 ) such that their logarithms 00048 *> are uniformly distributed. 00049 *> MODE = 6 set D to random numbers from same distribution 00050 *> as the rest of the matrix. 00051 *> MODE < 0 has the same meaning as ABS(MODE), except that 00052 *> the order of the elements of D is reversed. 00053 *> Thus if MODE is positive, D has entries ranging from 00054 *> 1 to 1/COND, if negative, from 1/COND to 1, 00055 *> Not modified. 00056 *> \endverbatim 00057 *> 00058 *> \param[in] COND 00059 *> \verbatim 00060 *> COND is REAL 00061 *> On entry, used as described under MODE above. 00062 *> If used, it must be >= 1. Not modified. 00063 *> \endverbatim 00064 *> 00065 *> \param[in] IRSIGN 00066 *> \verbatim 00067 *> IRSIGN is INTEGER 00068 *> On entry, if MODE neither -6, 0 nor 6, determines sign of 00069 *> entries of D 00070 *> 0 => leave entries of D unchanged 00071 *> 1 => multiply each entry of D by 1 or -1 with probability .5 00072 *> \endverbatim 00073 *> 00074 *> \param[in] IDIST 00075 *> \verbatim 00076 *> IDIST is CHARACTER*1 00077 *> On entry, IDIST specifies the type of distribution to be 00078 *> used to generate a random matrix . 00079 *> 1 => UNIFORM( 0, 1 ) 00080 *> 2 => UNIFORM( -1, 1 ) 00081 *> 3 => NORMAL( 0, 1 ) 00082 *> Not modified. 00083 *> \endverbatim 00084 *> 00085 *> \param[in,out] ISEED 00086 *> \verbatim 00087 *> ISEED is INTEGER array, dimension ( 4 ) 00088 *> On entry ISEED specifies the seed of the random number 00089 *> generator. The random number generator uses a 00090 *> linear congruential sequence limited to small 00091 *> integers, and so should produce machine independent 00092 *> random numbers. The values of ISEED are changed on 00093 *> exit, and can be used in the next call to SLATM1 00094 *> to continue the same random number sequence. 00095 *> Changed on exit. 00096 *> \endverbatim 00097 *> 00098 *> \param[in,out] D 00099 *> \verbatim 00100 *> D is REAL array, dimension ( MIN( M , N ) ) 00101 *> Array to be computed according to MODE, COND and IRSIGN. 00102 *> May be changed on exit if MODE is nonzero. 00103 *> \endverbatim 00104 *> 00105 *> \param[in] N 00106 *> \verbatim 00107 *> N is INTEGER 00108 *> Number of entries of D. Not modified. 00109 *> \endverbatim 00110 *> 00111 *> \param[out] INFO 00112 *> \verbatim 00113 *> INFO is INTEGER 00114 *> 0 => normal termination 00115 *> -1 => if MODE not in range -6 to 6 00116 *> -2 => if MODE neither -6, 0 nor 6, and 00117 *> IRSIGN neither 0 nor 1 00118 *> -3 => if MODE neither -6, 0 nor 6 and COND less than 1 00119 *> -4 => if MODE equals 6 or -6 and IDIST not in range 1 to 3 00120 *> -7 => if N negative 00121 *> \endverbatim 00122 * 00123 * Authors: 00124 * ======== 00125 * 00126 *> \author Univ. of Tennessee 00127 *> \author Univ. of California Berkeley 00128 *> \author Univ. of Colorado Denver 00129 *> \author NAG Ltd. 00130 * 00131 *> \date November 2011 00132 * 00133 *> \ingroup real_matgen 00134 * 00135 * ===================================================================== 00136 SUBROUTINE SLATM1( MODE, COND, IRSIGN, IDIST, ISEED, D, N, INFO ) 00137 * 00138 * -- LAPACK auxiliary routine (version 3.4.0) -- 00139 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00140 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00141 * November 2011 00142 * 00143 * .. Scalar Arguments .. 00144 INTEGER IDIST, INFO, IRSIGN, MODE, N 00145 REAL COND 00146 * .. 00147 * .. Array Arguments .. 00148 INTEGER ISEED( 4 ) 00149 REAL D( * ) 00150 * .. 00151 * 00152 * ===================================================================== 00153 * 00154 * .. Parameters .. 00155 REAL ONE 00156 PARAMETER ( ONE = 1.0E0 ) 00157 REAL HALF 00158 PARAMETER ( HALF = 0.5E0 ) 00159 * .. 00160 * .. Local Scalars .. 00161 INTEGER I 00162 REAL ALPHA, TEMP 00163 * .. 00164 * .. External Functions .. 00165 REAL SLARAN 00166 EXTERNAL SLARAN 00167 * .. 00168 * .. External Subroutines .. 00169 EXTERNAL SLARNV, XERBLA 00170 * .. 00171 * .. Intrinsic Functions .. 00172 INTRINSIC ABS, EXP, LOG, REAL 00173 * .. 00174 * .. Executable Statements .. 00175 * 00176 * Decode and Test the input parameters. Initialize flags & seed. 00177 * 00178 INFO = 0 00179 * 00180 * Quick return if possible 00181 * 00182 IF( N.EQ.0 ) 00183 $ RETURN 00184 * 00185 * Set INFO if an error 00186 * 00187 IF( MODE.LT.-6 .OR. MODE.GT.6 ) THEN 00188 INFO = -1 00189 ELSE IF( ( MODE.NE.-6 .AND. MODE.NE.0 .AND. MODE.NE.6 ) .AND. 00190 $ ( IRSIGN.NE.0 .AND. IRSIGN.NE.1 ) ) THEN 00191 INFO = -2 00192 ELSE IF( ( MODE.NE.-6 .AND. MODE.NE.0 .AND. MODE.NE.6 ) .AND. 00193 $ COND.LT.ONE ) THEN 00194 INFO = -3 00195 ELSE IF( ( MODE.EQ.6 .OR. MODE.EQ.-6 ) .AND. 00196 $ ( IDIST.LT.1 .OR. IDIST.GT.3 ) ) THEN 00197 INFO = -4 00198 ELSE IF( N.LT.0 ) THEN 00199 INFO = -7 00200 END IF 00201 * 00202 IF( INFO.NE.0 ) THEN 00203 CALL XERBLA( 'SLATM1', -INFO ) 00204 RETURN 00205 END IF 00206 * 00207 * Compute D according to COND and MODE 00208 * 00209 IF( MODE.NE.0 ) THEN 00210 GO TO ( 10, 30, 50, 70, 90, 110 )ABS( MODE ) 00211 * 00212 * One large D value: 00213 * 00214 10 CONTINUE 00215 DO 20 I = 1, N 00216 D( I ) = ONE / COND 00217 20 CONTINUE 00218 D( 1 ) = ONE 00219 GO TO 120 00220 * 00221 * One small D value: 00222 * 00223 30 CONTINUE 00224 DO 40 I = 1, N 00225 D( I ) = ONE 00226 40 CONTINUE 00227 D( N ) = ONE / COND 00228 GO TO 120 00229 * 00230 * Exponentially distributed D values: 00231 * 00232 50 CONTINUE 00233 D( 1 ) = ONE 00234 IF( N.GT.1 ) THEN 00235 ALPHA = COND**( -ONE / REAL( N-1 ) ) 00236 DO 60 I = 2, N 00237 D( I ) = ALPHA**( I-1 ) 00238 60 CONTINUE 00239 END IF 00240 GO TO 120 00241 * 00242 * Arithmetically distributed D values: 00243 * 00244 70 CONTINUE 00245 D( 1 ) = ONE 00246 IF( N.GT.1 ) THEN 00247 TEMP = ONE / COND 00248 ALPHA = ( ONE-TEMP ) / REAL( N-1 ) 00249 DO 80 I = 2, N 00250 D( I ) = REAL( N-I )*ALPHA + TEMP 00251 80 CONTINUE 00252 END IF 00253 GO TO 120 00254 * 00255 * Randomly distributed D values on ( 1/COND , 1): 00256 * 00257 90 CONTINUE 00258 ALPHA = LOG( ONE / COND ) 00259 DO 100 I = 1, N 00260 D( I ) = EXP( ALPHA*SLARAN( ISEED ) ) 00261 100 CONTINUE 00262 GO TO 120 00263 * 00264 * Randomly distributed D values from IDIST 00265 * 00266 110 CONTINUE 00267 CALL SLARNV( IDIST, ISEED, N, D ) 00268 * 00269 120 CONTINUE 00270 * 00271 * If MODE neither -6 nor 0 nor 6, and IRSIGN = 1, assign 00272 * random signs to D 00273 * 00274 IF( ( MODE.NE.-6 .AND. MODE.NE.0 .AND. MODE.NE.6 ) .AND. 00275 $ IRSIGN.EQ.1 ) THEN 00276 DO 130 I = 1, N 00277 TEMP = SLARAN( ISEED ) 00278 IF( TEMP.GT.HALF ) 00279 $ D( I ) = -D( I ) 00280 130 CONTINUE 00281 END IF 00282 * 00283 * Reverse if MODE < 0 00284 * 00285 IF( MODE.LT.0 ) THEN 00286 DO 140 I = 1, N / 2 00287 TEMP = D( I ) 00288 D( I ) = D( N+1-I ) 00289 D( N+1-I ) = TEMP 00290 140 CONTINUE 00291 END IF 00292 * 00293 END IF 00294 * 00295 RETURN 00296 * 00297 * End of SLATM1 00298 * 00299 END