1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
#ifndef HPC_ULMBLAS_IAMAX_H
#define HPC_ULMBLAS_IAMAX_H 1

#include <cmath>

namespace hpc { namespace ulmblas {

template <typename Index, typename TX>
Index
iamax(Index n, const TX *x, Index incX)
{
    Index i0=0;

    for (Index i=1; i<n; ++i) {
        if (std::abs(x[i*incX])>std::abs(x[i0*incX])) {
            i0 = i;
        }
    }

    return i0;
}

} } // namespace ulmblas, hpc

#endif // HPC_ULMBLAS_IAMAX_H