KokkosBlas::nrminf¶
Defined in header: KokkosBlas1_nrminf.hpp
template <class execution_space, class XVector, typename std::enable_if<Kokkos::is_execution_space_v<execution_space>, int>::type = 0>
typename KokkosKernels::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type
nrminf(const execution_space& space, const XVector& x);
template <class XVector>
typename KokkosKernels::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type
nrminf(const XVector& x);
template <class execution_space, class RV, class XMV>
void nrminf(const execution_space& space, const RV& R, const XMV& X,
typename std::enable_if<Kokkos::is_view_v<RV>, int>::type = 0);
template <class RV, class XMV>
void nrminf(const RV& R, const XMV& X, typename std::enable_if<Kokkos::is_view_v<RV>, int>::type = 0)
Computes the norm inf (maximum absolute value) of the X vector(s) and returns or stores the result in R.
returns the largest magnitude in
Xand fences thespaceinstance.returns the largest magnitude in
Xand fences the default instance oftypename XVector::execution_space.returns the largest magnitude in each column of
X, stores it in the corresponding entry ofRand fences thespaceinstance.returns the largest magnitude in each column of
X, stores it in the corresponding entry ofRand fences the default instance oftypename XVector::execution_space.
The result (returned or stored value) is undefined if X has no entries.
Note: For 3. and 4. the return view is expected to be templated on Kokkos::HostSpace, the function will fail with a segfault at runtime otherwise.
Parameters¶
- space:
execution space instance
- X:
vector(s) to compute the norminf
- R:
computed norm(s)
Type Requirements¶
execution_space must be a Kokkos execution space
XVector must be a Kokkos View of rank 1 that satisfies
Kokkos::SpaceAccessibility<execution_space, typename XVector::memory_space>::accessible == true
XMV must be a Kokkos View of rank 1 or 2 that satisfies
Kokkos::SpaceAccessibility<execution_space, typename XMV::memory_space>::accessible == true
RV must be a Kokkos View that satisfies
RV::rank == XMV::rank - 1std::is_same_v<typename RV::value_type, typename RV::non_const_value_type> == truestd::is_same_v<typename RV::value_type, typename KokkosKernels::Details::InnerProductSpaceTraits<typename XMV::non_const_value_type>::mag_type> == trueRV::memory_space == Kokkos::HostSpace
Example¶
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright Contributors to the Kokkos project
#include <iostream>
#include <Kokkos_Core.hpp>
#include <KokkosBlas1_nrminf.hpp>
int main(void) {
Kokkos::initialize();
{
Kokkos::View<double*> x("X", 101);
Kokkos::parallel_for(
101, KOKKOS_LAMBDA(const int idx) {
const double val = static_cast<double>(idx) / 10;
x(idx) = (val - 10) * (val - 5) * val + 1.9;
});
double x_nrm = KokkosBlas::nrminf(x);
std::cout << "X_nrm: " << x_nrm << " Expected: " << 50.011 << std::endl;
}
Kokkos::finalize();
}
output:
X_nrm: 50.011 Expected: 50.011