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.

icmax1.f 3.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. *> \brief \b ICMAX1 finds the index of the first vector element of maximum absolute value.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ICMAX1 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/icmax1.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/icmax1.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/icmax1.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * INTEGER FUNCTION ICMAX1( N, CX, INCX )
  22. *
  23. * .. Scalar Arguments ..
  24. * INTEGER INCX, N
  25. * ..
  26. * .. Array Arguments ..
  27. * COMPLEX CX( * )
  28. * ..
  29. *
  30. *
  31. *> \par Purpose:
  32. * =============
  33. *>
  34. *> \verbatim
  35. *>
  36. *> ICMAX1 finds the index of the first vector element of maximum absolute value.
  37. *>
  38. *> Based on ICAMAX from Level 1 BLAS.
  39. *> The change is to use the 'genuine' absolute value.
  40. *> \endverbatim
  41. *
  42. * Arguments:
  43. * ==========
  44. *
  45. *> \param[in] N
  46. *> \verbatim
  47. *> N is INTEGER
  48. *> The number of elements in the vector CX.
  49. *> \endverbatim
  50. *>
  51. *> \param[in] CX
  52. *> \verbatim
  53. *> CX is COMPLEX array, dimension (N)
  54. *> The vector CX. The ICMAX1 function returns the index of its first
  55. *> element of maximum absolute value.
  56. *> \endverbatim
  57. *>
  58. *> \param[in] INCX
  59. *> \verbatim
  60. *> INCX is INTEGER
  61. *> The spacing between successive values of CX. INCX >= 1.
  62. *> \endverbatim
  63. *
  64. * Authors:
  65. * ========
  66. *
  67. *> \author Univ. of Tennessee
  68. *> \author Univ. of California Berkeley
  69. *> \author Univ. of Colorado Denver
  70. *> \author NAG Ltd.
  71. *
  72. *> \ingroup complexOTHERauxiliary
  73. *
  74. *> \par Contributors:
  75. * ==================
  76. *>
  77. *> Nick Higham for use with CLACON.
  78. *
  79. * =====================================================================
  80. INTEGER FUNCTION ICMAX1( N, CX, INCX )
  81. *
  82. * -- LAPACK auxiliary routine --
  83. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  84. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  85. *
  86. * .. Scalar Arguments ..
  87. INTEGER INCX, N
  88. * ..
  89. * .. Array Arguments ..
  90. COMPLEX CX(*)
  91. * ..
  92. *
  93. * =====================================================================
  94. *
  95. * .. Local Scalars ..
  96. REAL SMAX
  97. INTEGER I, IX
  98. * ..
  99. * .. Intrinsic Functions ..
  100. INTRINSIC ABS
  101. * ..
  102. * .. Executable Statements ..
  103. *
  104. ICMAX1 = 0
  105. IF (N.LT.1 .OR. INCX.LE.0) RETURN
  106. ICMAX1 = 1
  107. IF (N.EQ.1) RETURN
  108. IF (INCX.EQ.1) THEN
  109. *
  110. * code for increment equal to 1
  111. *
  112. SMAX = ABS(CX(1))
  113. DO I = 2,N
  114. IF (ABS(CX(I)).GT.SMAX) THEN
  115. ICMAX1 = I
  116. SMAX = ABS(CX(I))
  117. END IF
  118. END DO
  119. ELSE
  120. *
  121. * code for increment not equal to 1
  122. *
  123. IX = 1
  124. SMAX = ABS(CX(1))
  125. IX = IX + INCX
  126. DO I = 2,N
  127. IF (ABS(CX(IX)).GT.SMAX) THEN
  128. ICMAX1 = I
  129. SMAX = ABS(CX(IX))
  130. END IF
  131. IX = IX + INCX
  132. END DO
  133. END IF
  134. RETURN
  135. *
  136. * End of ICMAX1
  137. *
  138. END