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.

isamax.f 2.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. *> \brief \b ISAMAX
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * INTEGER FUNCTION ISAMAX(N,SX,INCX)
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INCX,N
  15. * ..
  16. * .. Array Arguments ..
  17. * REAL SX(*)
  18. * ..
  19. *
  20. *
  21. *> \par Purpose:
  22. * =============
  23. *>
  24. *> \verbatim
  25. *>
  26. *> ISAMAX finds the index of the first element having maximum absolute value.
  27. *> \endverbatim
  28. *
  29. * Authors:
  30. * ========
  31. *
  32. *> \author Univ. of Tennessee
  33. *> \author Univ. of California Berkeley
  34. *> \author Univ. of Colorado Denver
  35. *> \author NAG Ltd.
  36. *
  37. *> \date November 2015
  38. *
  39. *> \ingroup aux_blas
  40. *
  41. *> \par Further Details:
  42. * =====================
  43. *>
  44. *> \verbatim
  45. *>
  46. *> jack dongarra, linpack, 3/11/78.
  47. *> modified 3/93 to return if incx .le. 0.
  48. *> modified 12/3/93, array(1) declarations changed to array(*)
  49. *> \endverbatim
  50. *>
  51. * =====================================================================
  52. INTEGER FUNCTION ISAMAX(N,SX,INCX)
  53. *
  54. * -- Reference BLAS level1 routine (version 3.6.0) --
  55. * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
  56. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  57. * November 2015
  58. *
  59. * .. Scalar Arguments ..
  60. INTEGER INCX,N
  61. * ..
  62. * .. Array Arguments ..
  63. REAL SX(*)
  64. * ..
  65. *
  66. * =====================================================================
  67. *
  68. * .. Local Scalars ..
  69. REAL SMAX
  70. INTEGER I,IX
  71. * ..
  72. * .. Intrinsic Functions ..
  73. INTRINSIC ABS
  74. * ..
  75. ISAMAX = 0
  76. IF (N.LT.1 .OR. INCX.LE.0) RETURN
  77. ISAMAX = 1
  78. IF (N.EQ.1) RETURN
  79. IF (INCX.EQ.1) THEN
  80. *
  81. * code for increment equal to 1
  82. *
  83. SMAX = ABS(SX(1))
  84. DO I = 2,N
  85. IF (ABS(SX(I)).GT.SMAX) THEN
  86. ISAMAX = I
  87. SMAX = ABS(SX(I))
  88. END IF
  89. END DO
  90. ELSE
  91. *
  92. * code for increment not equal to 1
  93. *
  94. IX = 1
  95. SMAX = ABS(SX(1))
  96. IX = IX + INCX
  97. DO I = 2,N
  98. IF (ABS(SX(IX)).GT.SMAX) THEN
  99. ISAMAX = I
  100. SMAX = ABS(SX(IX))
  101. END IF
  102. IX = IX + INCX
  103. END DO
  104. END IF
  105. RETURN
  106. END