| 1 | C @(#)linpack100.for 19.1 (ES0-DMD) 02/25/03 14:35:47 |
| 2 | C=========================================================================== |
| 3 | C Copyright (C) 1995 European Southern Observatory (ESO) |
| 4 | C |
| 5 | C This program is free software; you can redistribute it and/or |
| 6 | C modify it under the terms of the GNU General Public License as |
| 7 | C published by the Free Software Foundation; either version 2 of |
| 8 | C the License, or (at your option) any later version. |
| 9 | C |
| 10 | C This program is distributed in the hope that it will be useful, |
| 11 | C but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | C GNU General Public License for more details. |
| 14 | C |
| 15 | C You should have received a copy of the GNU General Public |
| 16 | C License along with this program; if not, write to the Free |
| 17 | C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, |
| 18 | C MA 02139, USA. |
| 19 | C |
| 20 | C Corresponding concerning ESO-MIDAS should be addressed as follows: |
| 21 | C Internet e-mail: [email protected] |
| 22 | C Postal address: European Southern Observatory |
| 23 | C Data Management Division |
| 24 | C Karl-Schwarzschild-Strasse 2 |
| 25 | C D 85748 Garching bei Muenchen |
| 26 | C GERMANY |
| 27 | C=========================================================================== |
| 28 | C |
| 29 | double precision aa(200,200),a(201,200),b(200),x(200) |
| 30 | double precision time(8,6),cray,ops,total,norma,normx |
| 31 | double precision resid,residn,eps,epslon |
| 32 | integer ipvt(200) |
| 33 | call nosci(15) |
| 34 | lda = 201 |
| 35 | ldaa = 200 |
| 36 | c |
| 37 | n = 100 |
| 38 | cray = .056 |
| 39 | c write(6,1) |
| 40 | c 1 format(' Please send the results of this run to:'// |
| 41 | c $ ' Jack J. Dongarra'/ |
| 42 | c $ ' Mathematics and Computer Science Division'/ |
| 43 | c $ ' Argonne National Laboratory'/ |
| 44 | c $ ' Argonne, Illinois 60439'// |
| 45 | c $ ' Telephone: 312-972-7246'// |
| 46 | c $ ' ARPAnet: DONGARRA@ANL-MCS'/) |
| 47 | ops = (2.0d0*n**3)/3.0d0 + 2.0d0*n**2 |
| 48 | c |
| 49 | call matgen(a,lda,n,b,norma) |
| 50 | t1 = second() |
| 51 | call dgefa(a,lda,n,ipvt,info) |
| 52 | time(1,1) = second() - t1 |
| 53 | t1 = second() |
| 54 | call dgesl(a,lda,n,ipvt,b,0) |
| 55 | time(1,2) = second() - t1 |
| 56 | total = time(1,1) + time(1,2) |
| 57 | c |
| 58 | c compute a residual to verify results. |
| 59 | c |
| 60 | do 10 i = 1,n |
| 61 | x(i) = b(i) |
| 62 | 10 continue |
| 63 | call matgen(a,lda,n,b,norma) |
| 64 | do 20 i = 1,n |
| 65 | b(i) = -b(i) |
| 66 | 20 continue |
| 67 | call dmxpy(n,b,n,lda,x,a) |
| 68 | resid = 0.0 |
| 69 | normx = 0.0 |
| 70 | do 30 i = 1,n |
| 71 | resid = dmax1( resid, dabs(b(i)) ) |
| 72 | normx = dmax1( normx, dabs(x(i)) ) |
| 73 | 30 continue |
| 74 | eps = epslon(1.0d0) |
| 75 | residn = resid/( n*norma*normx*eps ) |
| 76 | write(6,40) |
| 77 | 40 format(' norm. resid resid machep', |
| 78 | $ ' x(1) x(n)') |
| 79 | write(6,50) residn,resid,eps,x(1),x(n) |
| 80 | 50 format(1p5e16.8) |
| 81 | c |
| 82 | write(6,60) n |
| 83 | 60 format(//' times are reported for matrices of order ',i5) |
| 84 | write(6,70) |
| 85 | 70 format(6x,'dgefa',6x,'dgesl',6x,'total',5x,'mflops',7x,'unit', |
| 86 | $ 6x,'ratio') |
| 87 | c |
| 88 | time(1,3) = total |
| 89 | time(1,4) = ops/(1.0d6*total) |
| 90 | time(1,5) = 2.0d0/time(1,4) |
| 91 | time(1,6) = total/cray |
| 92 | write(6,80) lda |
| 93 | 80 format(' times for array with leading dimension of',i4) |
| 94 | write(6,110) (time(1,i),i=1,6) |
| 95 | c |
| 96 | call matgen(a,lda,n,b,norma) |
| 97 | t1 = second() |
| 98 | call dgefa(a,lda,n,ipvt,info) |
| 99 | time(2,1) = second() - t1 |
| 100 | t1 = second() |
| 101 | call dgesl(a,lda,n,ipvt,b,0) |
| 102 | time(2,2) = second() - t1 |
| 103 | total = time(2,1) + time(2,2) |
| 104 | time(2,3) = total |
| 105 | time(2,4) = ops/(1.0d6*total) |
| 106 | time(2,5) = 2.0d0/time(2,4) |
| 107 | time(2,6) = total/cray |
| 108 | c |
| 109 | call matgen(a,lda,n,b,norma) |
| 110 | t1 = second() |
| 111 | call dgefa(a,lda,n,ipvt,info) |
| 112 | time(3,1) = second() - t1 |
| 113 | t1 = second() |
| 114 | call dgesl(a,lda,n,ipvt,b,0) |
| 115 | time(3,2) = second() - t1 |
| 116 | total = time(3,1) + time(3,2) |
| 117 | time(3,3) = total |
| 118 | time(3,4) = ops/(1.0d6*total) |
| 119 | time(3,5) = 2.0d0/time(3,4) |
| 120 | time(3,6) = total/cray |
| 121 | c |
| 122 | ntimes = 10 |
| 123 | tm2 = 0 |
| 124 | t1 = second() |
| 125 | do 90 i = 1,ntimes |
| 126 | tm = second() |
| 127 | call matgen(a,lda,n,b,norma) |
| 128 | tm2 = tm2 + second() - tm |
| 129 | call dgefa(a,lda,n,ipvt,info) |
| 130 | 90 continue |
| 131 | time(4,1) = (second() - t1 - tm2)/ntimes |
| 132 | t1 = second() |
| 133 | do 100 i = 1,ntimes |
| 134 | call dgesl(a,lda,n,ipvt,b,0) |
| 135 | 100 continue |
| 136 | time(4,2) = (second() - t1)/ntimes |
| 137 | total = time(4,1) + time(4,2) |
| 138 | time(4,3) = total |
| 139 | time(4,4) = ops/(1.0d6*total) |
| 140 | time(4,5) = 2.0d0/time(4,4) |
| 141 | time(4,6) = total/cray |
| 142 | c |
| 143 | write(6,110) (time(2,i),i=1,6) |
| 144 | write(6,110) (time(3,i),i=1,6) |
| 145 | write(6,110) (time(4,i),i=1,6) |
| 146 | 110 format(6(1pe11.3)) |
| 147 | c |
| 148 | call matgen(aa,ldaa,n,b,norma) |
| 149 | t1 = second() |
| 150 | call dgefa(aa,ldaa,n,ipvt,info) |
| 151 | time(5,1) = second() - t1 |
| 152 | t1 = second() |
| 153 | call dgesl(aa,ldaa,n,ipvt,b,0) |
| 154 | time(5,2) = second() - t1 |
| 155 | total = time(5,1) + time(5,2) |
| 156 | time(5,3) = total |
| 157 | time(5,4) = ops/(1.0d6*total) |
| 158 | time(5,5) = 2.0d0/time(5,4) |
| 159 | time(5,6) = total/cray |
| 160 | c |
| 161 | call matgen(aa,ldaa,n,b,norma) |
| 162 | t1 = second() |
| 163 | call dgefa(aa,ldaa,n,ipvt,info) |
| 164 | time(6,1) = second() - t1 |
| 165 | t1 = second() |
| 166 | call dgesl(aa,ldaa,n,ipvt,b,0) |
| 167 | time(6,2) = second() - t1 |
| 168 | total = time(6,1) + time(6,2) |
| 169 | time(6,3) = total |
| 170 | time(6,4) = ops/(1.0d6*total) |
| 171 | time(6,5) = 2.0d0/time(6,4) |
| 172 | time(6,6) = total/cray |
| 173 | c |
| 174 | call matgen(aa,ldaa,n,b,norma) |
| 175 | t1 = second() |
| 176 | call dgefa(aa,ldaa,n,ipvt,info) |
| 177 | time(7,1) = second() - t1 |
| 178 | t1 = second() |
| 179 | call dgesl(aa,ldaa,n,ipvt,b,0) |
| 180 | time(7,2) = second() - t1 |
| 181 | total = time(7,1) + time(7,2) |
| 182 | time(7,3) = total |
| 183 | time(7,4) = ops/(1.0d6*total) |
| 184 | time(7,5) = 2.0d0/time(7,4) |
| 185 | time(7,6) = total/cray |
| 186 | c |
| 187 | ntimes = 10 |
| 188 | tm2 = 0 |
| 189 | t1 = second() |
| 190 | do 120 i = 1,ntimes |
| 191 | tm = second() |
| 192 | call matgen(aa,ldaa,n,b,norma) |
| 193 | tm2 = tm2 + second() - tm |
| 194 | call dgefa(aa,ldaa,n,ipvt,info) |
| 195 | 120 continue |
| 196 | time(8,1) = (second() - t1 - tm2)/ntimes |
| 197 | t1 = second() |
| 198 | do 130 i = 1,ntimes |
| 199 | call dgesl(aa,ldaa,n,ipvt,b,0) |
| 200 | 130 continue |
| 201 | time(8,2) = (second() - t1)/ntimes |
| 202 | total = time(8,1) + time(8,2) |
| 203 | time(8,3) = total |
| 204 | time(8,4) = ops/(1.0d6*total) |
| 205 | time(8,5) = 2.0d0/time(8,4) |
| 206 | time(8,6) = total/cray |
| 207 | c |
| 208 | write(6,140) ldaa |
| 209 | 140 format(/' times for array with leading dimension of',i4) |
| 210 | write(6,110) (time(5,i),i=1,6) |
| 211 | write(6,110) (time(6,i),i=1,6) |
| 212 | write(6,110) (time(7,i),i=1,6) |
| 213 | write(6,110) (time(8,i),i=1,6) |
| 214 | sum=0. |
| 215 | do 160 i=1,4 |
| 216 | sum=sum+time(i,4) |
| 217 | 160 continue |
| 218 | sum=sum/4.0 |
| 219 | write(15,165)sum |
| 220 | 165 format('MFLOPS =',F8.2) |
| 221 | call noscf() |
| 222 | stop |
| 223 | end |
| 224 | subroutine matgen(a,lda,n,b,norma) |
| 225 | double precision a(lda,1),b(1),norma |
| 226 | c |
| 227 | init = 1325 |
| 228 | norma = 0.0 |
| 229 | do 30 j = 1,n |
| 230 | do 20 i = 1,n |
| 231 | init = mod(3125*init,65536) |
| 232 | a(i,j) = (init - 32768.0)/16384.0 |
| 233 | norma = dmax1(a(i,j), norma) |
| 234 | 20 continue |
| 235 | 30 continue |
| 236 | do 35 i = 1,n |
| 237 | b(i) = 0.0 |
| 238 | 35 continue |
| 239 | do 50 j = 1,n |
| 240 | do 40 i = 1,n |
| 241 | b(i) = b(i) + a(i,j) |
| 242 | 40 continue |
| 243 | 50 continue |
| 244 | return |
| 245 | end |
| 246 | subroutine dgefa(a,lda,n,ipvt,info) |
| 247 | integer lda,n,ipvt(1),info |
| 248 | double precision a(lda,1) |
| 249 | c |
| 250 | c dgefa factors a double precision matrix by gaussian elimination. |
| 251 | c |
| 252 | c dgefa is usually called by dgeco, but it can be called |
| 253 | c directly with a saving in time if rcond is not needed. |
| 254 | c (time for dgeco) = (1 + 9/n)*(time for dgefa) . |
| 255 | c |
| 256 | c on entry |
| 257 | c |
| 258 | c a double precision(lda, n) |
| 259 | c the matrix to be factored. |
| 260 | c |
| 261 | c lda integer |
| 262 | c the leading dimension of the array a . |
| 263 | c |
| 264 | c n integer |
| 265 | c the order of the matrix a . |
| 266 | c |
| 267 | c on return |
| 268 | c |
| 269 | c a an upper triangular matrix and the multipliers |
| 270 | c which were used to obtain it. |
| 271 | c the factorization can be written a = l*u where |
| 272 | c l is a product of permutation and unit lower |
| 273 | c triangular matrices and u is upper triangular. |
| 274 | c |
| 275 | c ipvt integer(n) |
| 276 | c an integer vector of pivot indices. |
| 277 | c |
| 278 | c info integer |
| 279 | c = 0 normal value. |
| 280 | c = k if u(k,k) .eq. 0.0 . this is not an error |
| 281 | c condition for this subroutine, but it does |
| 282 | c indicate that dgesl or dgedi will divide by zero |
| 283 | c if called. use rcond in dgeco for a reliable |
| 284 | c indication of singularity. |
| 285 | c |
| 286 | c linpack. this version dated 08/14/78 . |
| 287 | c cleve moler, university of new mexico, argonne national lab. |
| 288 | c |
| 289 | c subroutines and functions |
| 290 | c |
| 291 | c blas daxpy,dscal,idamax |
| 292 | c |
| 293 | c internal variables |
| 294 | c |
| 295 | double precision t |
| 296 | integer idamax,j,k,kp1,l,nm1 |
| 297 | c |
| 298 | c |
| 299 | c gaussian elimination with partial pivoting |
| 300 | c |
| 301 | info = 0 |
| 302 | nm1 = n - 1 |
| 303 | if (nm1 .lt. 1) go to 70 |
| 304 | do 60 k = 1, nm1 |
| 305 | kp1 = k + 1 |
| 306 | c |
| 307 | c find l = pivot index |
| 308 | c |
| 309 | l = idamax(n-k+1,a(k,k),1) + k - 1 |
| 310 | ipvt(k) = l |
| 311 | c |
| 312 | c zero pivot implies this column already triangularized |
| 313 | c |
| 314 | if (a(l,k) .eq. 0.0d0) go to 40 |
| 315 | c |
| 316 | c interchange if necessary |
| 317 | c |
| 318 | if (l .eq. k) go to 10 |
| 319 | t = a(l,k) |
| 320 | a(l,k) = a(k,k) |
| 321 | a(k,k) = t |
| 322 | 10 continue |
| 323 | c |
| 324 | c compute multipliers |
| 325 | c |
| 326 | t = -1.0d0/a(k,k) |
| 327 | call dscal(n-k,t,a(k+1,k),1) |
| 328 | c |
| 329 | c row elimination with column indexing |
| 330 | c |
| 331 | do 30 j = kp1, n |
| 332 | t = a(l,j) |
| 333 | if (l .eq. k) go to 20 |
| 334 | a(l,j) = a(k,j) |
| 335 | a(k,j) = t |
| 336 | 20 continue |
| 337 | call daxpy(n-k,t,a(k+1,k),1,a(k+1,j),1) |
| 338 | 30 continue |
| 339 | go to 50 |
| 340 | 40 continue |
| 341 | info = k |
| 342 | 50 continue |
| 343 | 60 continue |
| 344 | 70 continue |
| 345 | ipvt(n) = n |
| 346 | if (a(n,n) .eq. 0.0d0) info = n |
| 347 | return |
| 348 | end |
| 349 | subroutine dgesl(a,lda,n,ipvt,b,job) |
| 350 | integer lda,n,ipvt(1),job |
| 351 | double precision a(lda,1),b(1) |
| 352 | c |
| 353 | c dgesl solves the double precision system |
| 354 | c a * x = b or trans(a) * x = b |
| 355 | c using the factors computed by dgeco or dgefa. |
| 356 | c |
| 357 | c on entry |
| 358 | c |
| 359 | c a double precision(lda, n) |
| 360 | c the output from dgeco or dgefa. |
| 361 | c |
| 362 | c lda integer |
| 363 | c the leading dimension of the array a . |
| 364 | c |
| 365 | c n integer |
| 366 | c the order of the matrix a . |
| 367 | c |
| 368 | c ipvt integer(n) |
| 369 | c the pivot vector from dgeco or dgefa. |
| 370 | c |
| 371 | c b double precision(n) |
| 372 | c the right hand side vector. |
| 373 | c |
| 374 | c job integer |
| 375 | c = 0 to solve a*x = b , |
| 376 | c = nonzero to solve trans(a)*x = b where |
| 377 | c trans(a) is the transpose. |
| 378 | c |
| 379 | c on return |
| 380 | c |
| 381 | c b the solution vector x . |
| 382 | c |
| 383 | c error condition |
| 384 | c |
| 385 | c a division by zero will occur if the input factor contains a |
| 386 | c zero on the diagonal. technically this indicates singularity |
| 387 | c but it is often caused by improper arguments or improper |
| 388 | c setting of lda . it will not occur if the subroutines are |
| 389 | c called correctly and if dgeco has set rcond .gt. 0.0 |
| 390 | c or dgefa has set info .eq. 0 . |
| 391 | c |
| 392 | c to compute inverse(a) * c where c is a matrix |
| 393 | c with p columns |
| 394 | c call dgeco(a,lda,n,ipvt,rcond,z) |
| 395 | c if (rcond is too small) go to ... |
| 396 | c do 10 j = 1, p |
| 397 | c call dgesl(a,lda,n,ipvt,c(1,j),0) |
| 398 | c 10 continue |
| 399 | c |
| 400 | c linpack. this version dated 08/14/78 . |
| 401 | c cleve moler, university of new mexico, argonne national lab. |
| 402 | c |
| 403 | c subroutines and functions |
| 404 | c |
| 405 | c blas daxpy,ddot |
| 406 | c |
| 407 | c internal variables |
| 408 | c |
| 409 | double precision ddot,t |
| 410 | integer k,kb,l,nm1 |
| 411 | c |
| 412 | nm1 = n - 1 |
| 413 | if (job .ne. 0) go to 50 |
| 414 | c |
| 415 | c job = 0 , solve a * x = b |
| 416 | c first solve l*y = b |
| 417 | c |
| 418 | if (nm1 .lt. 1) go to 30 |
| 419 | do 20 k = 1, nm1 |
| 420 | l = ipvt(k) |
| 421 | t = b(l) |
| 422 | if (l .eq. k) go to 10 |
| 423 | b(l) = b(k) |
| 424 | b(k) = t |
| 425 | 10 continue |
| 426 | call daxpy(n-k,t,a(k+1,k),1,b(k+1),1) |
| 427 | 20 continue |
| 428 | 30 continue |
| 429 | c |
| 430 | c now solve u*x = y |
| 431 | c |
| 432 | do 40 kb = 1, n |
| 433 | k = n + 1 - kb |
| 434 | b(k) = b(k)/a(k,k) |
| 435 | t = -b(k) |
| 436 | call daxpy(k-1,t,a(1,k),1,b(1),1) |
| 437 | 40 continue |
| 438 | go to 100 |
| 439 | 50 continue |
| 440 | c |
| 441 | c job = nonzero, solve trans(a) * x = b |
| 442 | c first solve trans(u)*y = b |
| 443 | c |
| 444 | do 60 k = 1, n |
| 445 | t = ddot(k-1,a(1,k),1,b(1),1) |
| 446 | b(k) = (b(k) - t)/a(k,k) |
| 447 | 60 continue |
| 448 | c |
| 449 | c now solve trans(l)*x = y |
| 450 | c |
| 451 | if (nm1 .lt. 1) go to 90 |
| 452 | do 80 kb = 1, nm1 |
| 453 | k = n - kb |
| 454 | b(k) = b(k) + ddot(n-k,a(k+1,k),1,b(k+1),1) |
| 455 | l = ipvt(k) |
| 456 | if (l .eq. k) go to 70 |
| 457 | t = b(l) |
| 458 | b(l) = b(k) |
| 459 | b(k) = t |
| 460 | 70 continue |
| 461 | 80 continue |
| 462 | 90 continue |
| 463 | 100 continue |
| 464 | return |
| 465 | end |
| 466 | subroutine daxpy(n,da,dx,incx,dy,incy) |
| 467 | c |
| 468 | c constant times a vector plus a vector. |
| 469 | c jack dongarra, linpack, 3/11/78. |
| 470 | c |
| 471 | double precision dx(1),dy(1),da |
| 472 | integer i,incx,incy,ix,iy,m,mp1,n |
| 473 | c |
| 474 | if(n.le.0)return |
| 475 | if (da .eq. 0.0d0) return |
| 476 | if(incx.eq.1.and.incy.eq.1)go to 20 |
| 477 | c |
| 478 | c code for unequal increments or equal increments |
| 479 | c not equal to 1 |
| 480 | c |
| 481 | ix = 1 |
| 482 | iy = 1 |
| 483 | if(incx.lt.0)ix = (-n+1)*incx + 1 |
| 484 | if(incy.lt.0)iy = (-n+1)*incy + 1 |
| 485 | do 10 i = 1,n |
| 486 | dy(iy) = dy(iy) + da*dx(ix) |
| 487 | ix = ix + incx |
| 488 | iy = iy + incy |
| 489 | 10 continue |
| 490 | return |
| 491 | c |
| 492 | c code for both increments equal to 1 |
| 493 | c |
| 494 | 20 continue |
| 495 | do 30 i = 1,n |
| 496 | dy(i) = dy(i) + da*dx(i) |
| 497 | 30 continue |
| 498 | return |
| 499 | end |
| 500 | double precision function ddot(n,dx,incx,dy,incy) |
| 501 | c |
| 502 | c forms the dot product of two vectors. |
| 503 | c jack dongarra, linpack, 3/11/78. |
| 504 | c |
| 505 | double precision dx(1),dy(1),dtemp |
| 506 | integer i,incx,incy,ix,iy,m,mp1,n |
| 507 | c |
| 508 | ddot = 0.0d0 |
| 509 | dtemp = 0.0d0 |
| 510 | if(n.le.0)return |
| 511 | if(incx.eq.1.and.incy.eq.1)go to 20 |
| 512 | c |
| 513 | c code for unequal increments or equal increments |
| 514 | c not equal to 1 |
| 515 | c |
| 516 | ix = 1 |
| 517 | iy = 1 |
| 518 | if(incx.lt.0)ix = (-n+1)*incx + 1 |
| 519 | if(incy.lt.0)iy = (-n+1)*incy + 1 |
| 520 | do 10 i = 1,n |
| 521 | dtemp = dtemp + dx(ix)*dy(iy) |
| 522 | ix = ix + incx |
| 523 | iy = iy + incy |
| 524 | 10 continue |
| 525 | ddot = dtemp |
| 526 | return |
| 527 | c |
| 528 | c code for both increments equal to 1 |
| 529 | c |
| 530 | 20 continue |
| 531 | do 30 i = 1,n |
| 532 | dtemp = dtemp + dx(i)*dy(i) |
| 533 | 30 continue |
| 534 | ddot = dtemp |
| 535 | return |
| 536 | end |
| 537 | subroutine dscal(n,da,dx,incx) |
| 538 | c |
| 539 | c scales a vector by a constant. |
| 540 | c jack dongarra, linpack, 3/11/78. |
| 541 | c |
| 542 | double precision da,dx(1) |
| 543 | integer i,incx,m,mp1,n,nincx |
| 544 | c |
| 545 | if(n.le.0)return |
| 546 | if(incx.eq.1)go to 20 |
| 547 | c |
| 548 | c code for increment not equal to 1 |
| 549 | c |
| 550 | nincx = n*incx |
| 551 | do 10 i = 1,nincx,incx |
| 552 | dx(i) = da*dx(i) |
| 553 | 10 continue |
| 554 | return |
| 555 | c |
| 556 | c code for increment equal to 1 |
| 557 | c |
| 558 | 20 continue |
| 559 | do 30 i = 1,n |
| 560 | dx(i) = da*dx(i) |
| 561 | 30 continue |
| 562 | return |
| 563 | end |
| 564 | integer function idamax(n,dx,incx) |
| 565 | c |
| 566 | c finds the index of element having max. dabsolute value. |
| 567 | c jack dongarra, linpack, 3/11/78. |
| 568 | c |
| 569 | double precision dx(1),dmax |
| 570 | integer i,incx,ix,n |
| 571 | c |
| 572 | idamax = 0 |
| 573 | if( n .lt. 1 ) return |
| 574 | idamax = 1 |
| 575 | if(n.eq.1)return |
| 576 | if(incx.eq.1)go to 20 |
| 577 | c |
| 578 | c code for increment not equal to 1 |
| 579 | c |
| 580 | ix = 1 |
| 581 | dmax = dabs(dx(1)) |
| 582 | ix = ix + incx |
| 583 | do 10 i = 2,n |
| 584 | if(dabs(dx(ix)).le.dmax) go to 5 |
| 585 | idamax = i |
| 586 | dmax = dabs(dx(ix)) |
| 587 | 5 ix = ix + incx |
| 588 | 10 continue |
| 589 | return |
| 590 | c |
| 591 | c code for increment equal to 1 |
| 592 | c |
| 593 | 20 dmax = dabs(dx(1)) |
| 594 | do 30 i = 2,n |
| 595 | if(dabs(dx(i)).le.dmax) go to 30 |
| 596 | idamax = i |
| 597 | dmax = dabs(dx(i)) |
| 598 | 30 continue |
| 599 | return |
| 600 | end |
| 601 | double precision function epslon (x) |
| 602 | double precision x |
| 603 | c |
| 604 | c estimate unit roundoff in quantities of size x. |
| 605 | c |
| 606 | double precision a,b,c,eps |
| 607 | c |
| 608 | c this program should function properly on all systems |
| 609 | c satisfying the following two assumptions, |
| 610 | c 1. the base used in representing dfloating point |
| 611 | c numbers is not a power of three. |
| 612 | c 2. the quantity a in statement 10 is represented to |
| 613 | c the accuracy used in dfloating point variables |
| 614 | c that are stored in memory. |
| 615 | c the statement number 10 and the go to 10 are intended to |
| 616 | c force optimizing compilers to generate code satisfying |
| 617 | c assumption 2. |
| 618 | c under these assumptions, it should be true that, |
| 619 | c a is not exactly equal to four-thirds, |
| 620 | c b has a zero for its last bit or digit, |
| 621 | c c is not exactly equal to one, |
| 622 | c eps measures the separation of 1.0 from |
| 623 | c the next larger dfloating point number. |
| 624 | c the developers of eispack would appreciate being informed |
| 625 | c about any systems where these assumptions do not hold. |
| 626 | c |
| 627 | c ***************************************************************** |
| 628 | c this routine is one of the auxiliary routines used by eispack iii |
| 629 | c to avoid machine dependencies. |
| 630 | c ***************************************************************** |
| 631 | c |
| 632 | c this version dated 4/6/83. |
| 633 | c |
| 634 | a = 4.0d0/3.0d0 |
| 635 | 10 b = a - 1.0d0 |
| 636 | c = b + b + b |
| 637 | eps = dabs(c-1.0d0) |
| 638 | if (eps .eq. 0.0d0) go to 10 |
| 639 | epslon = eps*dabs(x) |
| 640 | return |
| 641 | end |
| 642 | subroutine mm (a, lda, n1, n3, b, ldb, n2, c, ldc) |
| 643 | double precision a(lda,*), b(ldb,*), c(ldc,*) |
| 644 | c |
| 645 | c purpose: |
| 646 | c multiply matrix b times matrix c and store the result in matrix a. |
| 647 | c |
| 648 | c parameters: |
| 649 | c |
| 650 | c a double precision(lda,n3), matrix of n1 rows and n3 columns |
| 651 | c |
| 652 | c lda integer, leading dimension of array a |
| 653 | c |
| 654 | c n1 integer, number of rows in matrices a and b |
| 655 | c |
| 656 | c n3 integer, number of columns in matrices a and c |
| 657 | c |
| 658 | c b double precision(ldb,n2), matrix of n1 rows and n2 columns |
| 659 | c |
| 660 | c ldb integer, leading dimension of array b |
| 661 | c |
| 662 | c n2 integer, number of columns in matrix b, and number of rows in |
| 663 | c matrix c |
| 664 | c |
| 665 | c c double precision(ldc,n3), matrix of n2 rows and n3 columns |
| 666 | c |
| 667 | c ldc integer, leading dimension of array c |
| 668 | c |
| 669 | c ---------------------------------------------------------------------- |
| 670 | c |
| 671 | do 20 j = 1, n3 |
| 672 | do 10 i = 1, n1 |
| 673 | a(i,j) = 0.0 |
| 674 | 10 continue |
| 675 | call dmxpy (n2,a(1,j),n1,ldb,c(1,j),b) |
| 676 | 20 continue |
| 677 | c |
| 678 | return |
| 679 | end |
| 680 | subroutine dmxpy (n1, y, n2, ldm, x, m) |
| 681 | double precision y(*), x(*), m(ldm,*) |
| 682 | c |
| 683 | c purpose: |
| 684 | c multiply matrix m times vector x and add the result to vector y. |
| 685 | c |
| 686 | c parameters: |
| 687 | c |
| 688 | c n1 integer, number of elements in vector y, and number of rows in |
| 689 | c matrix m |
| 690 | c |
| 691 | c y double precision(n1), vector of length n1 to which is added |
| 692 | c the product m*x |
| 693 | c |
| 694 | c n2 integer, number of elements in vector x, and number of columns |
| 695 | c in matrix m |
| 696 | c |
| 697 | c ldm integer, leading dimension of array m |
| 698 | c |
| 699 | c x double precision(n2), vector of length n2 |
| 700 | c |
| 701 | c m double precision(ldm,n2), matrix of n1 rows and n2 columns |
| 702 | c |
| 703 | c ---------------------------------------------------------------------- |
| 704 | c |
| 705 | c cleanup odd vector |
| 706 | c |
| 707 | j = mod(n2,2) |
| 708 | if (j .ge. 1) then |
| 709 | do 10 i = 1, n1 |
| 710 | y(i) = (y(i)) + x(j)*m(i,j) |
| 711 | 10 continue |
| 712 | endif |
| 713 | c |
| 714 | c cleanup odd group of two vectors |
| 715 | c |
| 716 | j = mod(n2,4) |
| 717 | if (j .ge. 2) then |
| 718 | do 20 i = 1, n1 |
| 719 | y(i) = ( (y(i)) |
| 720 | $ + x(j-1)*m(i,j-1)) + x(j)*m(i,j) |
| 721 | 20 continue |
| 722 | endif |
| 723 | c |
| 724 | c cleanup odd group of four vectors |
| 725 | c |
| 726 | j = mod(n2,8) |
| 727 | if (j .ge. 4) then |
| 728 | do 30 i = 1, n1 |
| 729 | y(i) = ((( (y(i)) |
| 730 | $ + x(j-3)*m(i,j-3)) + x(j-2)*m(i,j-2)) |
| 731 | $ + x(j-1)*m(i,j-1)) + x(j) *m(i,j) |
| 732 | 30 continue |
| 733 | endif |
| 734 | c |
| 735 | c cleanup odd group of eight vectors |
| 736 | c |
| 737 | j = mod(n2,16) |
| 738 | if (j .ge. 8) then |
| 739 | do 40 i = 1, n1 |
| 740 | y(i) = ((((((( (y(i)) |
| 741 | $ + x(j-7)*m(i,j-7)) + x(j-6)*m(i,j-6)) |
| 742 | $ + x(j-5)*m(i,j-5)) + x(j-4)*m(i,j-4)) |
| 743 | $ + x(j-3)*m(i,j-3)) + x(j-2)*m(i,j-2)) |
| 744 | $ + x(j-1)*m(i,j-1)) + x(j) *m(i,j) |
| 745 | 40 continue |
| 746 | endif |
| 747 | c |
| 748 | c main loop - groups of sixteen vectors |
| 749 | c |
| 750 | jmin = j+16 |
| 751 | do 60 j = jmin, n2, 16 |
| 752 | do 50 i = 1, n1 |
| 753 | y(i) = ((((((((((((((( (y(i)) |
| 754 | $ + x(j-15)*m(i,j-15)) + x(j-14)*m(i,j-14)) |
| 755 | $ + x(j-13)*m(i,j-13)) + x(j-12)*m(i,j-12)) |
| 756 | $ + x(j-11)*m(i,j-11)) + x(j-10)*m(i,j-10)) |
| 757 | $ + x(j- 9)*m(i,j- 9)) + x(j- 8)*m(i,j- 8)) |
| 758 | $ + x(j- 7)*m(i,j- 7)) + x(j- 6)*m(i,j- 6)) |
| 759 | $ + x(j- 5)*m(i,j- 5)) + x(j- 4)*m(i,j- 4)) |
| 760 | $ + x(j- 3)*m(i,j- 3)) + x(j- 2)*m(i,j- 2)) |
| 761 | $ + x(j- 1)*m(i,j- 1)) + x(j) *m(i,j) |
| 762 | 50 continue |
| 763 | 60 continue |
| 764 | return |
| 765 | end |
| 766 |