10 #ifndef KOKKOS_BLAS1_UQ_PCE_HPP
11 #define KOKKOS_BLAS1_UQ_PCE_HPP
16 #include "KokkosBlas.hpp"
22 namespace KokkosBlas {
24 template <
typename XD,
typename ... XP,
25 typename YD,
typename ... YP>
26 typename std::enable_if<
29 typename Kokkos::Details::InnerProductSpaceTraits<
30 typename Kokkos::View<XD,XP...>::non_const_value_type >::dot_type
32 dot(
const Kokkos::View<XD,XP...>& x,
33 const Kokkos::View<YD,YP...>& y)
35 typedef Kokkos::View<XD,XP...> XVector;
36 typedef Kokkos::View<YD,YP...> YVector;
41 return dot( x_flat, y_flat );
44 template <
typename RV,
45 typename XD,
typename ... XP,
46 typename YD,
typename ... YP>
47 typename std::enable_if<
51 const Kokkos::View<XD,XP...>& x,
52 const Kokkos::View<YD,YP...>& y)
54 typedef Kokkos::View<XD,XP...> XVector;
55 typedef Kokkos::View<YD,YP...> YVector;
60 dot( r, x_flat, y_flat );
63 template <
typename XD,
typename ... XP>
64 typename std::enable_if<
66 fill(
const Kokkos::View<XD,XP...>& x,
67 const typename Kokkos::View<XD,XP...>::non_const_value_type&
val) {
68 typedef Kokkos::View<XD,XP...> XVector;
73 fill( x_flat, val.coeff(0) );
80 template <
typename RV,
81 typename XD,
typename ... XP>
82 typename std::enable_if<
86 const Kokkos::View<XD,XP...>& x)
88 typedef Kokkos::View<XD,XP...> XVector;
95 template <
typename RV,
96 typename XD,
typename ... XP>
97 typename std::enable_if<
101 const Kokkos::View<XD,XP...>& x)
103 typedef Kokkos::View<XD,XP...> XVector;
110 template <
typename RV,
111 typename XD,
typename ... XP>
112 typename std::enable_if<
116 const Kokkos::View<XD,XP...>& x)
118 typedef Kokkos::View<XD,XP...> XVector;
125 template <
typename AV,
126 typename XD,
typename ... XP,
128 typename YD,
typename ... YP>
129 typename std::enable_if<
133 const Kokkos::View<XD,XP...>& x,
135 const Kokkos::View<YD,YP...>& y)
137 typedef Kokkos::View<XD,XP...> XVector;
138 typedef Kokkos::View<YD,YP...> YVector;
146 auto aa = Sacado::Value<AV>::eval(a);
147 auto bb = Sacado::Value<BV>::eval(b);
148 axpby( aa, x_flat, bb, y_flat );
153 template <
typename RD,
typename ... RP,
154 typename XD,
typename ... XP>
155 typename std::enable_if<
158 scal(
const Kokkos::View<RD,RP...>& r,
159 const typename Kokkos::View<XD,XP...>::non_const_value_type& a,
160 const Kokkos::View<XD,XP...>& x)
162 typedef Kokkos::View<RD,RP...> RVector;
163 typedef Kokkos::View<XD,XP...> XVector;
171 scal( r_flat, a.coeff(0), x_flat );
179 template <
typename XD,
typename ... XP,
180 typename YD,
typename ... YP,
181 typename ZD,
typename ... ZP>
182 typename std::enable_if<
187 const typename Kokkos::View<XD,XP...>::array_type::non_const_value_type& alpha,
188 const Kokkos::View<XD,XP...>& x,
189 const typename Kokkos::View<YD,YP...>::array_type::non_const_value_type& beta,
190 const Kokkos::View<YD,YP...>& y,
191 const typename Kokkos::View<ZD,ZP...>::array_type::non_const_value_type& gamma,
192 const Kokkos::View<ZD,ZP...>& z)
194 typedef Kokkos::View<XD,XP...> XVector;
195 typedef Kokkos::View<YD,YP...> YVector;
196 typedef Kokkos::View<ZD,ZP...> ZVector;
202 update( alpha, x_flat, beta, y_flat, gamma, z_flat);
206 template <
typename XD,
typename ... XP,
207 typename YD,
typename ... YP,
208 typename ZD,
typename ... ZP>
209 typename std::enable_if<
214 const typename Kokkos::View<XD,XP...>::non_const_value_type& alpha,
215 const Kokkos::View<XD,XP...>& x,
216 const typename Kokkos::View<YD,YP...>::non_const_value_type& beta,
217 const Kokkos::View<YD,YP...>& y,
218 const typename Kokkos::View<ZD,ZP...>::non_const_value_type& gamma,
219 const Kokkos::View<ZD,ZP...>& z)
224 "update not implemented for non-constant alpha, beta, gamma");
227 update( alpha.coeff(0), x, beta.coeff(0), y, gamma.coeff(0), z );
233 template<
class RS,
class ... RP,
234 class XS,
class ... XP,
236 struct MV_Reciprocal_Functor<
237 Kokkos::
View<Sacado::UQ::PCE<RS>**,RP...>,
238 Kokkos::View<const Sacado::UQ::PCE<XS>**,XP...>,
241 typedef Kokkos::View<Sacado::UQ::PCE<RS>**,RP...>
RMV;
242 typedef Kokkos::View<const Sacado::UQ::PCE<XS>**,XP...>
XMV;
245 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<XMV>::type>
ATS;
252 numCols (X.extent(1)), R_ (R), X_ (X)
256 KOKKOS_INLINE_FUNCTION
259 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
263 R_(i,
j) = ATS::one () / X_(i,
j).fastAccessCoeff(0);
268 template<
class RS,
class ... RP,
270 struct MV_ReciprocalSelf_Functor<
271 Kokkos::
View<Sacado::UQ::PCE<RS>**,RP...>,
274 typedef Kokkos::View<Sacado::UQ::PCE<RS>**,RP...>
RMV;
277 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<RMV>::type>
ATS;
283 numCols (R.extent(1)), R_ (R)
287 KOKKOS_INLINE_FUNCTION
290 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
294 R_(i,
j) = ATS::one () / R_(i,
j).fastAccessCoeff(0);
299 template<
class RS,
class ... RP,
300 class XS,
class ... XP,
302 struct V_Reciprocal_Functor<
303 Kokkos::
View<Sacado::UQ::PCE<RS>*,RP...>,
304 Kokkos::View<const Sacado::UQ::PCE<XS>*,XP...>,
307 typedef Kokkos::View<Sacado::UQ::PCE<RS>*,RP...>
RV;
308 typedef Kokkos::View<const Sacado::UQ::PCE<XS>*,XP...>
XV;
311 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<XV>::type>
ATS;
320 KOKKOS_INLINE_FUNCTION
323 R_(i) = ATS::one () / X_(i).fastAccessCoeff(0);
327 template<
class RS,
class ... RP,
329 struct V_ReciprocalSelf_Functor<
330 Kokkos::
View<Sacado::UQ::PCE<RS>*,RP...>,
333 typedef Kokkos::View<Sacado::UQ::PCE<RS>*,RP...>
RV;
336 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<RV>::type>
ATS;
344 KOKKOS_INLINE_FUNCTION
347 R_(i) = ATS::one () / R_(i).fastAccessCoeff(0);
353 template <
typename RD,
typename ... RP,
354 typename XD,
typename ... XP>
355 typename std::enable_if<
359 const Kokkos::View<RD,RP...>& r,
360 const Kokkos::View<XD,XP...>& x)
362 typedef Kokkos::View<RD,RP...> RVector;
363 typedef Kokkos::View<XD,XP...> XVector;
367 sum( r_flat, x_flat );
370 template <
typename RD,
typename ... RP,
371 typename XD,
typename ... XP,
372 typename WD,
typename ... WP>
373 typename std::enable_if<
378 const Kokkos::View<RD,RP...>& r,
379 const Kokkos::View<XD,XP...>& x,
380 const Kokkos::View<WD,WP...>& w)
382 typedef Kokkos::View<RD,RP...> RVector;
383 typedef Kokkos::View<XD,XP...> XVector;
384 typedef Kokkos::View<WD,WP...> WVector;
395 template<
class CS,
class ... CP,
396 class AS,
class ... AP,
397 class BS,
class ... BP,
398 int scalar_ab,
int scalar_c,
class SizeType>
399 struct MV_MultFunctor<
400 Kokkos::
View<Sacado::UQ::PCE<CS>**,CP...>,
401 Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>,
402 Kokkos::View<const Sacado::UQ::PCE<BS>**,BP...>,
403 scalar_ab, scalar_c, SizeType>
405 typedef Kokkos::View<Sacado::UQ::PCE<CS>**,CP...>
CMV;
406 typedef Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>
AV;
407 typedef Kokkos::View<const Sacado::UQ::PCE<BS>**,BP...>
BMV;
410 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<CMV>::type>
ATS;
422 typename AV::const_value_type& ab,
427 m_c (c.coeff(0)), m_C (C), m_ab (ab.coeff(0)), m_A (A), m_B (B)
434 KOKKOS_INLINE_FUNCTION
void
438 if (scalar_ab == 0) {
440 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
444 m_C(i,
j).fastAccessCoeff(l) = ATS::zero ();
450 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
454 m_C(i,
j).fastAccessCoeff(l) =
455 m_ab * Ai * m_B(i,
j).fastAccessCoeff(l);
459 if (scalar_ab == 0) {
461 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
465 m_C(i,
j).fastAccessCoeff(l) = m_c * m_C(i,
j).fastAccessCoeff(l);
471 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
475 m_C(i,
j).fastAccessCoeff(l) =
476 m_c * m_C(i,
j).fastAccessCoeff(l) + m_ab * Ai * m_B(i,
j).fastAccessCoeff(l);
483 template<
class CS,
class ... CP,
484 class AS,
class ... AP,
485 class BS,
class ... BP,
486 int scalar_ab,
int scalar_c,
class SizeType>
487 struct V_MultFunctor<
488 Kokkos::
View<Sacado::UQ::PCE<CS>*,CP...>,
489 Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>,
490 Kokkos::View<const Sacado::UQ::PCE<BS>*,BP...>,
491 scalar_ab, scalar_c, SizeType>
493 typedef Kokkos::View<Sacado::UQ::PCE<CS>*,CP...>
CV;
494 typedef Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>
AV;
495 typedef Kokkos::View<const Sacado::UQ::PCE<BS>*,BP...>
BV;
498 typedef Kokkos::ArithTraits<typename Kokkos::IntrinsicScalarType<CV>::type>
ATS;
509 typename AV::const_value_type& ab,
513 m_c (c.coeff(0)), m_C (C), m_ab (ab.coeff(0)), m_A (A), m_B (B)
520 KOKKOS_INLINE_FUNCTION
void
524 if (scalar_ab == 0) {
525 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
529 m_C(i).fastAccessCoeff(l) = ATS::zero ();
533 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
537 m_C(i).fastAccessCoeff(l) = m_ab * Ai * m_B(i).fastAccessCoeff(l);
540 if (scalar_ab == 0) {
541 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
545 m_C(i).fastAccessCoeff(l) = m_c * m_C(i).fastAccessCoeff(l);
549 #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
553 m_C(i).fastAccessCoeff(l) =
554 m_c * m_C(i).fastAccessCoeff(l) + m_ab * Ai * m_B(i).fastAccessCoeff(l);
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< RMV >::type > ATS
RV::execution_space execution_space
Kokkos::View< const Sacado::UQ::PCE< BS > *, BP...> BV
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< XMV >::type > ATS
Kokkos::View< Sacado::UQ::PCE< RS > **, RP...> RMV
const Kokkos::IntrinsicScalarType< CMV >::type m_c
Kokkos::View< Sacado::UQ::PCE< CS > **, CP...> CMV
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< RV >::type > ATS
Kokkos::DefaultExecutionSpace execution_space
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< CMV >::type > ATS
Kokkos::View< const Sacado::UQ::PCE< BS > **, BP...> BMV
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP...> AV
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type fill(const Kokkos::View< XD, XP...> &x, const typename Kokkos::View< XD, XP...>::non_const_value_type &val)
Kokkos::View< const Sacado::UQ::PCE< XS > *, XP...> XV
KOKKOS_INLINE_FUNCTION void raise_error(const char *msg)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
RV::execution_space execution_space
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value, typename Kokkos::Details::InnerProductSpaceTraits< typename Kokkos::View< XD, XP...>::non_const_value_type >::dot_type >::type dot(const Kokkos::View< XD, XP...> &x, const Kokkos::View< YD, YP...> &y)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type nrm1(const RV &r, const Kokkos::View< XD, XP...> &x)
RMV::execution_space execution_space
const Kokkos::IntrinsicScalarType< AV >::type m_ab
CMV::execution_space execution_space
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< WD, WP...> >::value >::type nrm2w_squared(const Kokkos::View< RD, RP...> &r, const Kokkos::View< XD, XP...> &x, const Kokkos::View< WD, WP...> &w)
V_ReciprocalSelf_Functor(const RV &R)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type nrm2_squared(const RV &r, const Kokkos::View< XD, XP...> &x)
V_Reciprocal_Functor(const RV &R, const XV &X)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
MV_Reciprocal_Functor(const RMV &R, const XMV &X)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
MV_MultFunctor(typename CMV::const_value_type &c, const CMV &C, typename AV::const_value_type &ab, const AV &A, const BMV &B)
Kokkos::View< Sacado::UQ::PCE< RS > *, RP...> RV
RMV::execution_space execution_space
view_type::array_type::non_const_value_type type
Kokkos::View< Sacado::UQ::PCE< RS > **, RP...> RMV
CV::execution_space execution_space
Kokkos::View< Sacado::UQ::PCE< CS > *, CP...> CV
MV_ReciprocalSelf_Functor(const RMV &R)
Kokkos::View< Sacado::UQ::PCE< RS > *, RP...> RV
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< ZD, ZP...> >::value >::type update(const typename Kokkos::View< XD, XP...>::array_type::non_const_value_type &alpha, const Kokkos::View< XD, XP...> &x, const typename Kokkos::View< YD, YP...>::array_type::non_const_value_type &beta, const Kokkos::View< YD, YP...> &y, const typename Kokkos::View< ZD, ZP...>::array_type::non_const_value_type &gamma, const Kokkos::View< ZD, ZP...> &z)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type nrmInf(const RV &r, const Kokkos::View< XD, XP...> &x)
const Kokkos::IntrinsicScalarType< AV >::type m_ab
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< YD, YP...> >::value >::type axpby(const AV &a, const Kokkos::View< XD, XP...> &x, const BV &b, const Kokkos::View< YD, YP...> &y)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type scal(const Kokkos::View< RD, RP...> &r, const typename Kokkos::View< XD, XP...>::non_const_value_type &a, const Kokkos::View< XD, XP...> &x)
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP...> AV
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< XV >::type > ATS
const Kokkos::IntrinsicScalarType< CV >::type m_c
V_MultFunctor(typename CV::const_value_type &c, const CV &C, typename AV::const_value_type &ab, const AV &A, const BV &B)
Kokkos::ArithTraits< typename Kokkos::IntrinsicScalarType< CV >::type > ATS
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< RD, RP...> >::value &&Kokkos::is_view_uq_pce< Kokkos::View< XD, XP...> >::value >::type sum(const Kokkos::View< RD, RP...> &r, const Kokkos::View< XD, XP...> &x)
Kokkos::View< const Sacado::UQ::PCE< XS > **, XP...> XMV