Skip to content

BLAS 1::iamax

Vinh Dang edited this page Feb 17, 2020 · 12 revisions

KokkosBlas::iamax()

Header File: KokkosBlas1_iamax.hpp

Usage: nrm = KokkosBlas::iamax(x); KokkosBlas::iamax(r,x);

Return the (smallest) index of the element of the maximum magnitude of x.

Interface Single Vector Only

template<class XVector>
typename XVector::size_type iamax (const XVector& x);

Parameters:

  • XVector: a rank-1 Kokkos::View

Requirements:

  • x.rank == 1

Interface Single and MultiVector

template<class ReturnVector, class XVector>
void iamax (const ReturnVector& r, const XVector& x);

Parameters:

  • ReturnVector: a rank-0 or rank-1 Kokkos::View
  • XVector: a rank-1 or rank-2 Kokkos::View

Requirements:

  • x.rank == r.rank + 1
  • r.extent(0) == x.extent(1)
  • ReturnVector::non_const_value_type == ReturnVector::value_type
  • ReturnVector::value_type == XVector::size_type

Example

#include<Kokkos_Core.hpp>
#include<KokkosBlas1_nrm_inf.hpp>

int main(int argc, char* argv[]) {
   Kokkos::initialize();

   int N = atoi(argv[1]);

   Kokkos::View<double*> x("X",N);
   Kokkos::deep_copy(x,3.0);
   Kokkos::View<double> x_5(x,5);
   Kokkos::deep_copy(x,-7.5);

   double x_nrm = KokkosBlas::nrm_inf(x);

   printf("X_nrm: %lf Expected: %lf Diff: %e\n",x_nrm,7.5,x_nrm-7.5);

   Kokkos::finalize();
}
Clone this wiki locally