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.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. *> \brief \b ICMAX1 finds the index of the vector element whose real part has 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 element whose real part has maximum
  37. *> absolute value.
  38. *>
  39. *> Based on ICAMAX from Level 1 BLAS.
  40. *> The change is to use the 'genuine' absolute value.
  41. *> \endverbatim
  42. *
  43. * Arguments:
  44. * ==========
  45. *
  46. *> \param[in] N
  47. *> \verbatim
  48. *> N is INTEGER
  49. *> The number of elements in the vector CX.
  50. *> \endverbatim
  51. *>
  52. *> \param[in] CX
  53. *> \verbatim
  54. *> CX is COMPLEX array, dimension (N)
  55. *> The vector whose elements will be summed.
  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. *> \date September 2012
  73. *
  74. *> \ingroup complexOTHERauxiliary
  75. *
  76. *> \par Contributors:
  77. * ==================
  78. *>
  79. *> Nick Higham for use with CLACON.
  80. *
  81. * =====================================================================
  82. INTEGER FUNCTION ICMAX1( N, CX, INCX )
  83. *
  84. * -- LAPACK auxiliary routine (version 3.4.2) --
  85. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  86. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  87. * September 2012
  88. *
  89. * .. Scalar Arguments ..
  90. INTEGER INCX, N
  91. * ..
  92. * .. Array Arguments ..
  93. COMPLEX CX( * )
  94. * ..
  95. *
  96. * =====================================================================
  97. *
  98. * .. Local Scalars ..
  99. INTEGER I, IX
  100. REAL SMAX
  101. COMPLEX ZDUM
  102. * ..
  103. * .. Intrinsic Functions ..
  104. INTRINSIC ABS
  105. * ..
  106. * .. Statement Functions ..
  107. REAL CABS1
  108. * ..
  109. * .. Statement Function definitions ..
  110. *
  111. * NEXT LINE IS THE ONLY MODIFICATION.
  112. CABS1( ZDUM ) = ABS( ZDUM )
  113. * ..
  114. * .. Executable Statements ..
  115. *
  116. ICMAX1 = 0
  117. IF( N.LT.1 )
  118. $ RETURN
  119. ICMAX1 = 1
  120. IF( N.EQ.1 )
  121. $ RETURN
  122. IF( INCX.EQ.1 )
  123. $ GO TO 30
  124. *
  125. * CODE FOR INCREMENT NOT EQUAL TO 1
  126. *
  127. IX = 1
  128. SMAX = CABS1( CX( 1 ) )
  129. IX = IX + INCX
  130. DO 20 I = 2, N
  131. IF( CABS1( CX( IX ) ).LE.SMAX )
  132. $ GO TO 10
  133. ICMAX1 = I
  134. SMAX = CABS1( CX( IX ) )
  135. 10 CONTINUE
  136. IX = IX + INCX
  137. 20 CONTINUE
  138. RETURN
  139. *
  140. * CODE FOR INCREMENT EQUAL TO 1
  141. *
  142. 30 CONTINUE
  143. SMAX = CABS1( CX( 1 ) )
  144. DO 40 I = 2, N
  145. IF( CABS1( CX( I ) ).LE.SMAX )
  146. $ GO TO 40
  147. ICMAX1 = I
  148. SMAX = CABS1( CX( I ) )
  149. 40 CONTINUE
  150. RETURN
  151. *
  152. * End of ICMAX1
  153. *
  154. END