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.

iqamaxf.f 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. REAL*10 function qabs(dx)
  2. REAL*10 dx
  3. qabs = dx
  4. if (dx >= 0) return
  5. qabs = -dx
  6. return
  7. end
  8. integer function iqamaxf(n,dx,incx)
  9. c
  10. c finds the index of element having max. absolute value.
  11. c jack dongarra, linpack, 3/11/78.
  12. c modified 3/93 to return if incx .le. 0.
  13. c modified 12/3/93, array(1) declarations changed to array(*)
  14. c
  15. real*10 dx(*),dmax
  16. integer i,incx,ix,n
  17. c
  18. iqamaxf = 0
  19. if( n.lt.1 .or. incx.le.0 ) return
  20. iqamaxf = 1
  21. if(n.eq.1)return
  22. if(incx.eq.1)go to 20
  23. c
  24. c code for increment not equal to 1
  25. c
  26. ix = 1
  27. dmax = qabs(dx(1))
  28. ix = ix + incx
  29. do 10 i = 2,n
  30. if(qabs(dx(ix)).le.dmax) go to 5
  31. iqamaxf = i
  32. dmax = qabs(dx(ix))
  33. 5 ix = ix + incx
  34. 10 continue
  35. return
  36. c
  37. c code for increment equal to 1
  38. c
  39. 20 dmax = qabs(dx(1))
  40. do 30 i = 2,n
  41. if(qabs(dx(i)).le.dmax) go to 30
  42. iqamaxf = i
  43. dmax = qabs(dx(i))
  44. 30 continue
  45. return
  46. end