00001 /* slatm7.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Subroutine */ int slatm7_(integer *mode, real *cond, integer *irsign, 00017 integer *idist, integer *iseed, real *d__, integer *n, integer *rank, 00018 integer *info) 00019 { 00020 /* System generated locals */ 00021 integer i__1, i__2; 00022 doublereal d__1, d__2; 00023 00024 /* Builtin functions */ 00025 double pow_dd(doublereal *, doublereal *), pow_ri(real *, integer *), log( 00026 doublereal), exp(doublereal); 00027 00028 /* Local variables */ 00029 integer i__; 00030 real temp, alpha; 00031 extern /* Subroutine */ int xerbla_(char *, integer *); 00032 extern doublereal slaran_(integer *); 00033 extern /* Subroutine */ int slarnv_(integer *, integer *, integer *, real 00034 *); 00035 00036 00037 /* -- LAPACK test routine (version 3.1) -- */ 00038 /* Craig Lucas, University of Manchester / NAG Ltd. */ 00039 /* October, 2008 */ 00040 00041 /* .. Scalar Arguments .. */ 00042 /* .. */ 00043 /* .. Array Arguments .. */ 00044 /* .. */ 00045 00046 /* Purpose */ 00047 /* ======= */ 00048 00049 /* SLATM7 computes the entries of D as specified by MODE */ 00050 /* COND and IRSIGN. IDIST and ISEED determine the generation */ 00051 /* of random numbers. SLATM7 is called by SLATMT to generate */ 00052 /* random test matrices. */ 00053 00054 /* Arguments */ 00055 /* ========= */ 00056 00057 /* MODE - INTEGER */ 00058 /* On entry describes how D is to be computed: */ 00059 /* MODE = 0 means do not change D. */ 00060 00061 /* MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND */ 00062 /* MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND */ 00063 /* MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1)) I=1:RANK */ 00064 00065 /* MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */ 00066 /* MODE = 5 sets D to random numbers in the range */ 00067 /* ( 1/COND , 1 ) such that their logarithms */ 00068 /* are uniformly distributed. */ 00069 /* MODE = 6 set D to random numbers from same distribution */ 00070 /* as the rest of the matrix. */ 00071 /* MODE < 0 has the same meaning as ABS(MODE), except that */ 00072 /* the order of the elements of D is reversed. */ 00073 /* Thus if MODE is positive, D has entries ranging from */ 00074 /* 1 to 1/COND, if negative, from 1/COND to 1, */ 00075 /* Not modified. */ 00076 00077 /* COND - REAL */ 00078 /* On entry, used as described under MODE above. */ 00079 /* If used, it must be >= 1. Not modified. */ 00080 00081 /* IRSIGN - INTEGER */ 00082 /* On entry, if MODE neither -6, 0 nor 6, determines sign of */ 00083 /* entries of D */ 00084 /* 0 => leave entries of D unchanged */ 00085 /* 1 => multiply each entry of D by 1 or -1 with probability .5 */ 00086 00087 /* IDIST - CHARACTER*1 */ 00088 /* On entry, IDIST specifies the type of distribution to be */ 00089 /* used to generate a random matrix . */ 00090 /* 1 => UNIFORM( 0, 1 ) */ 00091 /* 2 => UNIFORM( -1, 1 ) */ 00092 /* 3 => NORMAL( 0, 1 ) */ 00093 /* Not modified. */ 00094 00095 /* ISEED - INTEGER array, dimension ( 4 ) */ 00096 /* On entry ISEED specifies the seed of the random number */ 00097 /* generator. The random number generator uses a */ 00098 /* linear congruential sequence limited to small */ 00099 /* integers, and so should produce machine independent */ 00100 /* random numbers. The values of ISEED are changed on */ 00101 /* exit, and can be used in the next call to SLATM7 */ 00102 /* to continue the same random number sequence. */ 00103 /* Changed on exit. */ 00104 00105 /* D - REAL array, dimension ( MIN( M , N ) ) */ 00106 /* Array to be computed according to MODE, COND and IRSIGN. */ 00107 /* May be changed on exit if MODE is nonzero. */ 00108 00109 /* N - INTEGER */ 00110 /* Number of entries of D. Not modified. */ 00111 00112 /* RANK - INTEGER */ 00113 /* The rank of matrix to be generated for modes 1,2,3 only. */ 00114 /* D( RANK+1:N ) = 0. */ 00115 /* Not modified. */ 00116 00117 /* INFO - INTEGER */ 00118 /* 0 => normal termination */ 00119 /* -1 => if MODE not in range -6 to 6 */ 00120 /* -2 => if MODE neither -6, 0 nor 6, and */ 00121 /* IRSIGN neither 0 nor 1 */ 00122 /* -3 => if MODE neither -6, 0 nor 6 and COND less than 1 */ 00123 /* -4 => if MODE equals 6 or -6 and IDIST not in range 1 to 3 */ 00124 /* -7 => if N negative */ 00125 00126 /* ===================================================================== */ 00127 00128 /* .. Parameters .. */ 00129 /* .. */ 00130 /* .. Local Scalars .. */ 00131 /* .. */ 00132 /* .. External Functions .. */ 00133 /* .. */ 00134 /* .. External Subroutines .. */ 00135 /* .. */ 00136 /* .. Intrinsic Functions .. */ 00137 /* .. */ 00138 /* .. Executable Statements .. */ 00139 00140 /* Decode and Test the input parameters. Initialize flags & seed. */ 00141 00142 /* Parameter adjustments */ 00143 --d__; 00144 --iseed; 00145 00146 /* Function Body */ 00147 *info = 0; 00148 00149 /* Quick return if possible */ 00150 00151 if (*n == 0) { 00152 return 0; 00153 } 00154 00155 /* Set INFO if an error */ 00156 00157 if (*mode < -6 || *mode > 6) { 00158 *info = -1; 00159 } else if (*mode != -6 && *mode != 0 && *mode != 6 && (*irsign != 0 && * 00160 irsign != 1)) { 00161 *info = -2; 00162 } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) { 00163 *info = -3; 00164 } else if ((*mode == 6 || *mode == -6) && (*idist < 1 || *idist > 3)) { 00165 *info = -4; 00166 } else if (*n < 0) { 00167 *info = -7; 00168 } 00169 00170 if (*info != 0) { 00171 i__1 = -(*info); 00172 xerbla_("SLATM7", &i__1); 00173 return 0; 00174 } 00175 00176 /* Compute D according to COND and MODE */ 00177 00178 if (*mode != 0) { 00179 switch (abs(*mode)) { 00180 case 1: goto L100; 00181 case 2: goto L130; 00182 case 3: goto L160; 00183 case 4: goto L190; 00184 case 5: goto L210; 00185 case 6: goto L230; 00186 } 00187 00188 /* One large D value: */ 00189 00190 L100: 00191 i__1 = *rank; 00192 for (i__ = 2; i__ <= i__1; ++i__) { 00193 d__[i__] = 1.f / *cond; 00194 /* L110: */ 00195 } 00196 i__1 = *n; 00197 for (i__ = *rank + 1; i__ <= i__1; ++i__) { 00198 d__[i__] = 0.f; 00199 /* L120: */ 00200 } 00201 d__[1] = 1.f; 00202 goto L240; 00203 00204 /* One small D value: */ 00205 00206 L130: 00207 i__1 = *rank - 1; 00208 for (i__ = 1; i__ <= i__1; ++i__) { 00209 d__[i__] = 1.f; 00210 /* L140: */ 00211 } 00212 i__1 = *n; 00213 for (i__ = *rank + 1; i__ <= i__1; ++i__) { 00214 d__[i__] = 0.f; 00215 /* L150: */ 00216 } 00217 d__[*rank] = 1.f / *cond; 00218 goto L240; 00219 00220 /* Exponentially distributed D values: */ 00221 00222 L160: 00223 d__[1] = 1.f; 00224 if (*n > 1) { 00225 d__1 = (doublereal) (*cond); 00226 d__2 = (doublereal) (-1.f / (real) (*rank - 1)); 00227 alpha = pow_dd(&d__1, &d__2); 00228 i__1 = *rank; 00229 for (i__ = 2; i__ <= i__1; ++i__) { 00230 i__2 = i__ - 1; 00231 d__[i__] = pow_ri(&alpha, &i__2); 00232 /* L170: */ 00233 } 00234 i__1 = *n; 00235 for (i__ = *rank + 1; i__ <= i__1; ++i__) { 00236 d__[i__] = 0.f; 00237 /* L180: */ 00238 } 00239 } 00240 goto L240; 00241 00242 /* Arithmetically distributed D values: */ 00243 00244 L190: 00245 d__[1] = 1.f; 00246 if (*n > 1) { 00247 temp = 1.f / *cond; 00248 alpha = (1.f - temp) / (real) (*n - 1); 00249 i__1 = *n; 00250 for (i__ = 2; i__ <= i__1; ++i__) { 00251 d__[i__] = (real) (*n - i__) * alpha + temp; 00252 /* L200: */ 00253 } 00254 } 00255 goto L240; 00256 00257 /* Randomly distributed D values on ( 1/COND , 1): */ 00258 00259 L210: 00260 alpha = log(1.f / *cond); 00261 i__1 = *n; 00262 for (i__ = 1; i__ <= i__1; ++i__) { 00263 d__[i__] = exp(alpha * slaran_(&iseed[1])); 00264 /* L220: */ 00265 } 00266 goto L240; 00267 00268 /* Randomly distributed D values from IDIST */ 00269 00270 L230: 00271 slarnv_(idist, &iseed[1], n, &d__[1]); 00272 00273 L240: 00274 00275 /* If MODE neither -6 nor 0 nor 6, and IRSIGN = 1, assign */ 00276 /* random signs to D */ 00277 00278 if (*mode != -6 && *mode != 0 && *mode != 6 && *irsign == 1) { 00279 i__1 = *n; 00280 for (i__ = 1; i__ <= i__1; ++i__) { 00281 temp = slaran_(&iseed[1]); 00282 if (temp > .5f) { 00283 d__[i__] = -d__[i__]; 00284 } 00285 /* L250: */ 00286 } 00287 } 00288 00289 /* Reverse if MODE < 0 */ 00290 00291 if (*mode < 0) { 00292 i__1 = *n / 2; 00293 for (i__ = 1; i__ <= i__1; ++i__) { 00294 temp = d__[i__]; 00295 d__[i__] = d__[*n + 1 - i__]; 00296 d__[*n + 1 - i__] = temp; 00297 /* L260: */ 00298 } 00299 } 00300 00301 } 00302 00303 return 0; 00304 00305 /* End of SLATM7 */ 00306 00307 } /* slatm7_ */