You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

idaminf.f 935 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. integer function idaminf(n,dx,incx)
  2. c
  3. c finds the index of element having min. absolute value.
  4. c jack dongarra, linpack, 3/11/78.
  5. c modified 3/93 to return if incx .le. 0.
  6. c modified 12/3/93, array(1) declarations changed to array(*)
  7. c
  8. double precision dx(*),dmin
  9. integer i,incx,ix,n
  10. c
  11. idaminf = 0
  12. if( n.lt.1 .or. incx.le.0 ) return
  13. idaminf = 1
  14. if(n.eq.1)return
  15. if(incx.eq.1)go to 20
  16. c
  17. c code for increment not equal to 1
  18. c
  19. ix = 1
  20. dmin = dabs(dx(1))
  21. ix = ix + incx
  22. do 10 i = 2,n
  23. if(dabs(dx(ix)).ge.dmin) go to 5
  24. idaminf = i
  25. dmin = dabs(dx(ix))
  26. 5 ix = ix + incx
  27. 10 continue
  28. return
  29. c
  30. c code for increment equal to 1
  31. c
  32. 20 dmin = dabs(dx(1))
  33. do 30 i = 2,n
  34. if(dabs(dx(i)).ge.dmin) go to 30
  35. idaminf = i
  36. dmin = dabs(dx(i))
  37. 30 continue
  38. return
  39. end