isamax.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* isamax.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. integer isamax_(integer *n, real *sx, integer *incx)
  14. {
  15. /* System generated locals */
  16. integer ret_val, i__1;
  17. real r__1;
  18. /* Local variables */
  19. integer i__, ix;
  20. real smax;
  21. /* .. Scalar Arguments .. */
  22. /* .. */
  23. /* .. Array Arguments .. */
  24. /* .. */
  25. /* Purpose */
  26. /* ======= */
  27. /* finds the index of element having max. absolute value. */
  28. /* jack dongarra, linpack, 3/11/78. */
  29. /* modified 3/93 to return if incx .le. 0. */
  30. /* modified 12/3/93, array(1) declarations changed to array(*) */
  31. /* .. Local Scalars .. */
  32. /* .. */
  33. /* .. Intrinsic Functions .. */
  34. /* .. */
  35. /* Parameter adjustments */
  36. --sx;
  37. /* Function Body */
  38. ret_val = 0;
  39. if (*n < 1 || *incx <= 0) {
  40. return ret_val;
  41. }
  42. ret_val = 1;
  43. if (*n == 1) {
  44. return ret_val;
  45. }
  46. if (*incx == 1) {
  47. goto L20;
  48. }
  49. /* code for increment not equal to 1 */
  50. ix = 1;
  51. smax = dabs(sx[1]);
  52. ix += *incx;
  53. i__1 = *n;
  54. for (i__ = 2; i__ <= i__1; ++i__) {
  55. if ((r__1 = sx[ix], dabs(r__1)) <= smax) {
  56. goto L5;
  57. }
  58. ret_val = i__;
  59. smax = (r__1 = sx[ix], dabs(r__1));
  60. L5:
  61. ix += *incx;
  62. /* L10: */
  63. }
  64. return ret_val;
  65. /* code for increment equal to 1 */
  66. L20:
  67. smax = dabs(sx[1]);
  68. i__1 = *n;
  69. for (i__ = 2; i__ <= i__1; ++i__) {
  70. if ((r__1 = sx[i__], dabs(r__1)) <= smax) {
  71. goto L30;
  72. }
  73. ret_val = i__;
  74. smax = (r__1 = sx[i__], dabs(r__1));
  75. L30:
  76. ;
  77. }
  78. return ret_val;
  79. } /* isamax_ */