KokkosBlas::nrm1¶
Defined in header: KokkosBlas1_nrm1.hpp
template <class execution_space, class XVector>
typename Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type
nrm1(const execution_space& space, const XVector& x);
template <class XVector>
typename Kokkos::Details::InnerProductSpaceTraits<typename XVector::non_const_value_type>::mag_type
nrm1(const XVector& x)
template <class execution_space, class RV, class XMV>
void nrm1(const execution_space& space, const RV& R, const XMV& X)
template <class RV, class XMV>
void nrm1(const RV& R, const XMV& X);
Computes the norm 1 (sum of absolute values) of the X vector(s) and returns or stores the result in R. Also known as asum.
accumulates the sum of absolute values of
Xand fences thespaceinstanceaccumulates the sum of absolute values of
Xand fences the default instance oftypename XVector::execution_spaceaccumulates the sum of absolute values of each column of
X, stores it in the corresponding entry ofRand fences thespaceinstanceaccumulates the sum of absolute values of 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.
Parameters¶
- space:
execution space instance
- X:
vector(s) to compute the norm1
- 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 Kokkos::Details::InnerProductSpaceTraits<typename XMV::non_const_value_type>::mag_type> == true
Example¶
#include <iostream>
#include <Kokkos_Core.hpp>
#include <KokkosBlas1_nrm1.hpp>
int main(void) {
Kokkos::initialize();
{
Kokkos::View<double*> x("X", 100);
Kokkos::deep_copy(x, -3.0);
double x_nrm = KokkosBlas::nrm1(x);
std::cout << "X_nrm: " << x_nrm << " Expected: " << 100 * 3.0 << std::endl;
}
Kokkos::finalize();
}
output:
X_nrm: 300 Expected: 300