42#ifndef KOKKOS_BLAS1_UQ_PCE_HPP
43#define KOKKOS_BLAS1_UQ_PCE_HPP
48#include "KokkosBlas.hpp"
56template <
typename XD,
typename ... XP,
57 typename YD,
typename ... YP>
58typename std::enable_if<
61 typename Kokkos::Details::InnerProductSpaceTraits<
62 typename Kokkos::View<XD,XP...>::non_const_value_type >::dot_type
64dot(
const Kokkos::View<XD,XP...>& x,
65 const Kokkos::View<YD,YP...>& y)
67 typedef Kokkos::View<XD,XP...> XVector;
68 typedef Kokkos::View<YD,YP...> YVector;
73 return dot( x_flat, y_flat );
77 typename XD,
typename ... XP,
78 typename YD,
typename ... YP>
79typename std::enable_if<
83 const Kokkos::View<XD,XP...>& x,
84 const Kokkos::View<YD,YP...>& y)
86 typedef Kokkos::View<XD,XP...> XVector;
87 typedef Kokkos::View<YD,YP...> YVector;
92 dot( r, x_flat, y_flat );
95template <
typename XD,
typename ... XP>
96typename std::enable_if<
98fill(
const Kokkos::View<XD,XP...>& x,
99 const typename Kokkos::View<XD,XP...>::non_const_value_type&
val) {
100 typedef Kokkos::View<XD,XP...> XVector;
108 Kokkos::deep_copy(x,
val);
112template <
typename RV,
113 typename XD,
typename ... XP>
114typename std::enable_if<
118 const Kokkos::View<XD,XP...>& x)
120 typedef Kokkos::View<XD,XP...> XVector;
127template <
typename RV,
128 typename XD,
typename ... XP>
129typename std::enable_if<
133 const Kokkos::View<XD,XP...>& x)
135 typedef Kokkos::View<XD,XP...> XVector;
142template <
typename RV,
143 typename XD,
typename ... XP>
144typename std::enable_if<
148 const Kokkos::View<XD,XP...>& x)
150 typedef Kokkos::View<XD,XP...> XVector;
157template <
typename AV,
158 typename XD,
typename ... XP,
160 typename YD,
typename ... YP>
161typename std::enable_if<
165 const Kokkos::View<XD,XP...>& x,
167 const Kokkos::View<YD,YP...>& y)
169 typedef Kokkos::View<XD,XP...> XVector;
170 typedef Kokkos::View<YD,YP...> YVector;
178 auto aa = Sacado::Value<AV>::eval(a);
179 auto bb = Sacado::Value<BV>::eval(b);
180 axpby( aa, x_flat, bb, y_flat );
185template <
typename RD,
typename ... RP,
186 typename XD,
typename ... XP>
187typename std::enable_if<
190scal(
const Kokkos::View<RD,RP...>& r,
191 const typename Kokkos::View<XD,XP...>::non_const_value_type& a,
192 const Kokkos::View<XD,XP...>& x)
194 typedef Kokkos::View<RD,RP...> RVector;
195 typedef Kokkos::View<XD,XP...> XVector;
203 scal( r_flat, a.coeff(0), x_flat );
211template <
typename XD,
typename ... XP,
212 typename YD,
typename ... YP,
213 typename ZD,
typename ... ZP>
214typename std::enable_if<
219 const typename Kokkos::View<XD,XP...>::array_type::non_const_value_type& alpha,
220 const Kokkos::View<XD,XP...>& x,
221 const typename Kokkos::View<YD,YP...>::array_type::non_const_value_type& beta,
222 const Kokkos::View<YD,YP...>& y,
223 const typename Kokkos::View<ZD,ZP...>::array_type::non_const_value_type& gamma,
224 const Kokkos::View<ZD,ZP...>& z)
226 typedef Kokkos::View<XD,XP...> XVector;
227 typedef Kokkos::View<YD,YP...> YVector;
228 typedef Kokkos::View<ZD,ZP...> ZVector;
234 update( alpha, x_flat, beta, y_flat, gamma, z_flat);
238template <
typename XD,
typename ... XP,
239 typename YD,
typename ... YP,
240 typename ZD,
typename ... ZP>
241typename std::enable_if<
246 const typename Kokkos::View<XD,XP...>::non_const_value_type& alpha,
247 const Kokkos::View<XD,XP...>& x,
248 const typename Kokkos::View<YD,YP...>::non_const_value_type& beta,
249 const Kokkos::View<YD,YP...>& y,
250 const typename Kokkos::View<ZD,ZP...>::non_const_value_type& gamma,
251 const Kokkos::View<ZD,ZP...>& z)
256 "update not implemented for non-constant alpha, beta, gamma");
259 update( alpha.coeff(0), x, beta.coeff(0), y, gamma.coeff(0), z );
265template<
class RS,
class ... RP,
266 class XS,
class ... XP,
268struct MV_Reciprocal_Functor<
270 Kokkos::View<const Sacado::UQ::PCE<XS>**,XP...>,
273 typedef Kokkos::View<Sacado::UQ::PCE<RS>**,RP...>
RMV;
274 typedef Kokkos::View<const Sacado::UQ::PCE<XS>**,XP...>
XMV;
277 typedef Kokkos::Details::ArithTraits<typename Kokkos::IntrinsicScalarType<XMV>::type>
ATS;
284 numCols (X.extent(1)), R_ (R), X_ (X)
288 KOKKOS_INLINE_FUNCTION
291#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
295 R_(i,
j) = ATS::one () / X_(i,
j).fastAccessCoeff(0);
300template<
class RS,
class ... RP,
302struct MV_ReciprocalSelf_Functor<
306 typedef Kokkos::View<Sacado::UQ::PCE<RS>**,RP...>
RMV;
309 typedef Kokkos::Details::ArithTraits<typename Kokkos::IntrinsicScalarType<RMV>::type>
ATS;
315 numCols (R.extent(1)), R_ (R)
319 KOKKOS_INLINE_FUNCTION
322#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
326 R_(i,
j) = ATS::one () / R_(i,
j).fastAccessCoeff(0);
331template<
class RS,
class ... RP,
332 class XS,
class ... XP,
334struct V_Reciprocal_Functor<
336 Kokkos::View<const Sacado::UQ::PCE<XS>*,XP...>,
339 typedef Kokkos::View<Sacado::UQ::PCE<RS>*,RP...>
RV;
340 typedef Kokkos::View<const Sacado::UQ::PCE<XS>*,XP...>
XV;
343 typedef Kokkos::Details::ArithTraits<typename Kokkos::IntrinsicScalarType<XV>::type>
ATS;
352 KOKKOS_INLINE_FUNCTION
355 R_(i) = ATS::one () / X_(i).fastAccessCoeff(0);
359template<
class RS,
class ... RP,
361struct V_ReciprocalSelf_Functor<
365 typedef Kokkos::View<Sacado::UQ::PCE<RS>*,RP...>
RV;
368 typedef Kokkos::Details::ArithTraits<typename Kokkos::IntrinsicScalarType<RV>::type>
ATS;
376 KOKKOS_INLINE_FUNCTION
379 R_(i) = ATS::one () / R_(i).fastAccessCoeff(0);
385template <
typename RD,
typename ... RP,
386 typename XD,
typename ... XP>
387typename std::enable_if<
391 const Kokkos::View<RD,RP...>& r,
392 const Kokkos::View<XD,XP...>& x)
394 typedef Kokkos::View<RD,RP...> RVector;
395 typedef Kokkos::View<XD,XP...> XVector;
399 sum( r_flat, x_flat );
402template <
typename RD,
typename ... RP,
403 typename XD,
typename ... XP,
404 typename WD,
typename ... WP>
405typename std::enable_if<
410 const Kokkos::View<RD,RP...>& r,
411 const Kokkos::View<XD,XP...>& x,
412 const Kokkos::View<WD,WP...>& w)
414 typedef Kokkos::View<RD,RP...> RVector;
415 typedef Kokkos::View<XD,XP...> XVector;
416 typedef Kokkos::View<WD,WP...> WVector;
427template<
class CS,
class ... CP,
428 class AS,
class ... AP,
429 class BS,
class ... BP,
430 int scalar_ab,
int scalar_c,
class SizeType>
431struct MV_MultFunctor<
433 Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>,
434 Kokkos::View<const Sacado::UQ::PCE<BS>**,BP...>,
435 scalar_ab, scalar_c, SizeType>
437 typedef Kokkos::View<Sacado::UQ::PCE<CS>**,CP...>
CMV;
438 typedef Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>
AV;
439 typedef Kokkos::View<const Sacado::UQ::PCE<BS>**,BP...>
BMV;
442 typedef Kokkos::Details::ArithTraits<typename Kokkos::IntrinsicScalarType<CMV>::type>
ATS;
454 typename AV::const_value_type& ab,
458 m_pce (dimension_scalar(C)),
459 m_c (c.coeff(0)), m_C (C), m_ab (ab.coeff(0)), m_A (A), m_B (B)
466 KOKKOS_INLINE_FUNCTION
void
470 if (scalar_ab == 0) {
472#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
476 m_C(i,
j).fastAccessCoeff(l) = ATS::zero ();
482#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
486 m_C(i,
j).fastAccessCoeff(l) =
487 m_ab * Ai * m_B(i,
j).fastAccessCoeff(l);
491 if (scalar_ab == 0) {
493#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
497 m_C(i,
j).fastAccessCoeff(l) = m_c * m_C(i,
j).fastAccessCoeff(l);
503#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
507 m_C(i,
j).fastAccessCoeff(l) =
508 m_c * m_C(i,
j).fastAccessCoeff(l) + m_ab * Ai * m_B(i,
j).fastAccessCoeff(l);
515template<
class CS,
class ... CP,
516 class AS,
class ... AP,
517 class BS,
class ... BP,
518 int scalar_ab,
int scalar_c,
class SizeType>
521 Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>,
522 Kokkos::View<const Sacado::UQ::PCE<BS>*,BP...>,
523 scalar_ab, scalar_c, SizeType>
525 typedef Kokkos::View<Sacado::UQ::PCE<CS>*,CP...>
CV;
526 typedef Kokkos::View<const Sacado::UQ::PCE<AS>*,AP...>
AV;
527 typedef Kokkos::View<const Sacado::UQ::PCE<BS>*,BP...>
BV;
530 typedef Kokkos::Details::ArithTraits<typename Kokkos::IntrinsicScalarType<CV>::type>
ATS;
541 typename AV::const_value_type& ab,
544 m_pce (dimension_scalar(C)),
545 m_c (c.coeff(0)), m_C (C), m_ab (ab.coeff(0)), m_A (A), m_B (B)
552 KOKKOS_INLINE_FUNCTION
void
556 if (scalar_ab == 0) {
557#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
561 m_C(i).fastAccessCoeff(l) = ATS::zero ();
565#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
569 m_C(i).fastAccessCoeff(l) = m_ab * Ai * m_B(i).fastAccessCoeff(l);
572 if (scalar_ab == 0) {
573#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
577 m_C(i).fastAccessCoeff(l) = m_c * m_C(i).fastAccessCoeff(l);
581#ifdef KOKKOS_ENABLE_PRAGMA_IVDEP
585 m_C(i).fastAccessCoeff(l) =
586 m_c * m_C(i).fastAccessCoeff(l) + m_ab * Ai * m_B(i).fastAccessCoeff(l);
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< XD, XP... > >::value >::type nrm1(const RV &r, const Kokkos::View< XD, XP... > &x)
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP... > >::value >::type nrmInf(const RV &r, const Kokkos::View< XD, XP... > &x)
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)
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)
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)
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)
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)
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< 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)
KOKKOS_INLINE_FUNCTION void raise_error(const char *msg)
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
Kokkos::View< const Sacado::UQ::PCE< BS > **, BP... > BMV
MV_MultFunctor(typename CMV::const_value_type &c, const CMV &C, typename AV::const_value_type &ab, const AV &A, const BMV &B)
const Kokkos::IntrinsicScalarType< AV >::type m_ab
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< CMV >::type > ATS
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP... > AV
CMV::execution_space execution_space
Kokkos::View< Sacado::UQ::PCE< CS > **, CP... > CMV
const Kokkos::IntrinsicScalarType< CMV >::type m_c
RMV::execution_space execution_space
Kokkos::View< Sacado::UQ::PCE< RS > **, RP... > RMV
MV_ReciprocalSelf_Functor(const RMV &R)
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< RMV >::type > ATS
Kokkos::View< const Sacado::UQ::PCE< XS > **, XP... > XMV
RMV::execution_space execution_space
MV_Reciprocal_Functor(const RMV &R, const XMV &X)
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< XMV >::type > ATS
Kokkos::View< Sacado::UQ::PCE< RS > **, RP... > RMV
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP... > AV
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< CV >::type > ATS
const Kokkos::IntrinsicScalarType< AV >::type m_ab
Kokkos::View< const Sacado::UQ::PCE< BS > *, BP... > BV
CV::execution_space execution_space
V_MultFunctor(typename CV::const_value_type &c, const CV &C, typename AV::const_value_type &ab, const AV &A, const BV &B)
Kokkos::View< Sacado::UQ::PCE< CS > *, CP... > CV
const Kokkos::IntrinsicScalarType< CV >::type m_c
Kokkos::View< Sacado::UQ::PCE< RS > *, RP... > RV
RV::execution_space execution_space
V_ReciprocalSelf_Functor(const RV &R)
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< RV >::type > ATS
V_Reciprocal_Functor(const RV &R, const XV &X)
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< XV >::type > ATS
RV::execution_space execution_space
Kokkos::View< Sacado::UQ::PCE< RS > *, RP... > RV
Kokkos::View< const Sacado::UQ::PCE< XS > *, XP... > XV
view_type::array_type::non_const_value_type type