42#ifndef KOKKOS_INNER_PRODUCT_SPACE_TRAITS_MP_VECTOR_HPP
43#define KOKKOS_INNER_PRODUCT_SPACE_TRAITS_MP_VECTOR_HPP
45#include "Sacado_ConfigDefs.h"
46#if defined(HAVE_STOKHOS_ENSEMBLE_REDUCT)
49#include "Kokkos_InnerProductSpaceTraits.hpp"
61class InnerProductSpaceTraits<
Sacado::MP::Vector<S> > {
65 typedef typename val_type::value_type base_value_type;
67 typedef InnerProductSpaceTraits<base_value_type> BIT;
68 typedef typename BIT::dot_type base_dot_type;
70 typedef typename ArithTraits<val_type>::mag_type mag_type;
71 typedef base_dot_type dot_type;
73 static KOKKOS_FORCEINLINE_FUNCTION
74 mag_type norm (
const val_type& x) {
77 mag_type nrm = mag_type(0);
78 for (ordinal_type i=0; i<sz; ++i) {
79 const mag_type n = BIT::norm(
x.fastAccessCoeff(i) );
82 return std::sqrt(nrm);
85 static KOKKOS_FORCEINLINE_FUNCTION
86 dot_type
dot (
const val_type& x,
const val_type& y) {
91 dot_type r = dot_type(0);
92 if (
x.hasFastAccess(sz) &&
y.hasFastAccess(sz))
93 for (ordinal_type i=0; i<sz; ++i)
94 r += BIT::dot(
x.fastAccessCoeff(i),
y.fastAccessCoeff(i) );
96 for (ordinal_type i=0; i<sz; ++i)
97 r += BIT::dot(
x.coeff(i),
y.coeff(i) );
105class InnerProductSpaceTraits< const
Sacado::MP::Vector<S> > {
109 typedef typename val_type::value_type base_value_type;
111 typedef InnerProductSpaceTraits<base_value_type> BIT;
112 typedef typename BIT::dot_type base_dot_type;
114 typedef typename ArithTraits<val_type>::mag_type mag_type;
115 typedef base_dot_type dot_type;
117 static KOKKOS_FORCEINLINE_FUNCTION
118 mag_type norm (
const val_type& x) {
121 mag_type nrm = mag_type(0);
122 for (ordinal_type i=0; i<sz; ++i) {
123 const mag_type n = BIT::norm(
x.fastAccessCoeff(i) );
126 return std::sqrt(nrm);
129 static KOKKOS_FORCEINLINE_FUNCTION
130 dot_type
dot (
const val_type& x,
const val_type& y) {
135 dot_type r = dot_type(0);
136 if (
x.hasFastAccess(sz) &&
y.hasFastAccess(sz))
137 for (ordinal_type i=0; i<sz; ++i)
138 r += BIT::dot(
x.fastAccessCoeff(i),
y.fastAccessCoeff(i) );
140 for (ordinal_type i=0; i<sz; ++i)
141 r += BIT::dot(
x.coeff(i),
y.coeff(i) );
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP... > >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP... > >::value, typenameKokkos::Details::InnerProductSpaceTraits< typenameKokkos::View< XD, XP... >::non_const_value_type >::dot_type >::type dot(const Kokkos::View< XD, XP... > &x, const Kokkos::View< YD, YP... > &y)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType ValueType * y