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.

icamaxf.f 967 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. integer function icamaxf(n,cx,incx)
  2. c
  3. c finds the index of element having max. 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. complex cx(*)
  9. real smax
  10. integer i,incx,ix,n
  11. real scabs1
  12. c
  13. icamaxf = 0
  14. if( n.lt.1 .or. incx.le.0 ) return
  15. icamaxf = 1
  16. if(n.eq.1)return
  17. if(incx.eq.1)go to 20
  18. c
  19. c code for increment not equal to 1
  20. c
  21. ix = 1
  22. smax = scabs1(cx(1))
  23. ix = ix + incx
  24. do 10 i = 2,n
  25. if(scabs1(cx(ix)).le.smax) go to 5
  26. icamaxf = i
  27. smax = scabs1(cx(ix))
  28. 5 ix = ix + incx
  29. 10 continue
  30. return
  31. c
  32. c code for increment equal to 1
  33. c
  34. 20 smax = scabs1(cx(1))
  35. do 30 i = 2,n
  36. if(scabs1(cx(i)).le.smax) go to 30
  37. icamaxf = i
  38. smax = scabs1(cx(i))
  39. 30 continue
  40. return
  41. end