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