| 819 | /******************************************************************************/ |
| 820 | |
| 821 | int idamax ( int n, double dx[], int incx ) |
| 822 | |
| 823 | /******************************************************************************/ |
| 824 | /* |
| 825 | Purpose: |
| 826 | |
| 827 | IDAMAX finds the index of the vector element of maximum absolute value. |
| 828 | |
| 829 | Discussion: |
| 830 | |
| 831 | WARNING: This index is a 1-based index, not a 0-based index! |
| 832 | |
| 833 | Modified: |
| 834 | |
| 835 | 30 March 2007 |
| 836 | |
| 837 | Author: |
| 838 | |
| 839 | FORTRAN77 original by Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart. |
| 840 | C version by John Burkardt |
| 841 | |
| 842 | Reference: |
| 843 | |
| 844 | Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart, |
| 845 | LINPACK User's Guide, |
| 846 | SIAM, 1979. |
| 847 | |
| 848 | Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, |
| 849 | Basic Linear Algebra Subprograms for Fortran Usage, |
| 850 | Algorithm 539, |
| 851 | ACM Transactions on Mathematical Software, |
| 852 | Volume 5, Number 3, September 1979, pages 308-323. |
| 853 | |
| 854 | Parameters: |
| 855 | |
| 856 | Input, int N, the number of entries in the vector. |
| 857 | |
| 858 | Input, double X[*], the vector to be examined. |
| 859 | |
| 860 | Input, int INCX, the increment between successive entries of SX. |
| 861 | |
| 862 | Output, int IDAMAX, the index of the element of maximum |
| 863 | absolute value. |
| 864 | */ |
| 865 | { |
| 866 | double dmax; |
| 867 | int i; |
| 868 | int ix; |
| 869 | int value; |
| 870 | |
| 871 | value = 0; |
| 872 | |
| 873 | if ( n < 1 || incx <= 0 ) |
| 874 | { |
| 875 | return value; |
| 876 | } |
| 877 | |
| 878 | value = 1; |