42 #ifndef KOKKOS_BLAS1_UQ_PCE_HPP 43 #define KOKKOS_BLAS1_UQ_PCE_HPP 48 #include "KokkosBlas.hpp" 56 template <
typename XD,
typename ... XP,
57 typename YD,
typename ... YP>
58 typename std::enable_if<
61 typename Kokkos::Details::InnerProductSpaceTraits<
62 typename Kokkos::View<XD,XP...>::non_const_value_type >::dot_type
64 dot(
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 );
76 template <
typename RV,
77 typename XD,
typename ... XP,
78 typename YD,
typename ... YP>
79 typename 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 );
95 template <
typename XD,
typename ... XP>
96 typename std::enable_if<
98 fill(
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;
112 template <
typename RV,
113 typename XD,
typename ... XP>
114 typename std::enable_if<
118 const Kokkos::View<XD,XP...>&
x)
120 typedef Kokkos::View<XD,XP...> XVector;
127 template <
typename RV,
128 typename XD,
typename ... XP>
129 typename std::enable_if<
133 const Kokkos::View<XD,XP...>&
x)
135 typedef Kokkos::View<XD,XP...> XVector;
142 template <
typename RV,
143 typename XD,
typename ... XP>
144 typename std::enable_if<
148 const Kokkos::View<XD,XP...>&
x)
150 typedef Kokkos::View<XD,XP...> XVector;
157 template <
typename AV,
158 typename XD,
typename ... XP,
160 typename YD,
typename ... YP>
161 typename 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 );
185 template <
typename RD,
typename ... RP,
186 typename XD,
typename ... XP>
187 typename std::enable_if<
190 scal(
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 );
211 template <
typename XD,
typename ... XP,
212 typename YD,
typename ... YP,
213 typename ZD,
typename ... ZP>
214 typename 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);
238 template <
typename XD,
typename ... XP,
239 typename YD,
typename ... YP,
240 typename ZD,
typename ... ZP>
241 typename 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 );
265 template<
class RS,
class ... RP,
266 class XS,
class ... XP,
268 struct 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);
300 template<
class RS,
class ... RP,
302 struct 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);
331 template<
class RS,
class ... RP,
332 class XS,
class ... XP,
334 struct 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);
359 template<
class RS,
class ... RP,
361 struct 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);
385 template <
typename RD,
typename ... RP,
386 typename XD,
typename ... XP>
387 typename 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 );
402 template <
typename RD,
typename ... RP,
403 typename XD,
typename ... XP,
404 typename WD,
typename ... WP>
405 typename 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;
427 template<
class CS,
class ... CP,
428 class AS,
class ... AP,
429 class BS,
class ... BP,
430 int scalar_ab,
int scalar_c,
class SizeType>
431 struct 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,
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);
515 template<
class CS,
class ... CP,
516 class AS,
class ... AP,
517 class BS,
class ... BP,
518 int scalar_ab,
int scalar_c,
class SizeType>
519 struct V_MultFunctor<
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,
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);
Kokkos::View< Sacado::UQ::PCE< RS > **, RP... > RMV
CMV::execution_space execution_space
std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< XD, XP... > >::value >::type nrm1(const RV &r, const Kokkos::View< XD, XP... > &x)
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP... > AV
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< RV >::type > ATS
Kokkos::View< Sacado::UQ::PCE< RS > **, RP... > RMV
Kokkos::DefaultExecutionSpace execution_space
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 >::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 nrmInf(const RV &r, 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 scal(const Kokkos::View< RD, RP... > &r, const typename Kokkos::View< XD, XP... >::non_const_value_type &a, const Kokkos::View< XD, XP... > &x)
const Kokkos::IntrinsicScalarType< CMV >::type m_c
KOKKOS_INLINE_FUNCTION void raise_error(const char *msg)
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
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< XMV >::type > ATS
Kokkos::View< const Sacado::UQ::PCE< AS > *, AP... > AV
V_MultFunctor(typename CV::const_value_type &c, const CV &C, typename AV::const_value_type &ab, const AV &A, const BV &B)
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< XV >::type > ATS
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
Kokkos::View< const Sacado::UQ::PCE< BS > **, BP... > BMV
V_Reciprocal_Functor(const RV &R, const XV &X)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P... > >::value, unsigned >::type dimension_scalar(const View< T, P... > &view)
RMV::execution_space execution_space
MV_Reciprocal_Functor(const RMV &R, const XMV &X)
RV::execution_space execution_space
KOKKOS_INLINE_FUNCTION bool is_constant(const T &x)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
Kokkos::View< Sacado::UQ::PCE< CS > *, CP... > CV
view_type::array_type::non_const_value_type type
RMV::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 &&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)
Kokkos::View< const Sacado::UQ::PCE< BS > *, BP... > BV
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< CMV >::type > ATS
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)
CV::execution_space execution_space
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)
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< RMV >::type > ATS
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
Kokkos::View< Sacado::UQ::PCE< CS > **, CP... > CMV
Kokkos::View< const Sacado::UQ::PCE< XS > *, XP... > XV
const Kokkos::IntrinsicScalarType< AV >::type m_ab
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)
const Kokkos::IntrinsicScalarType< CV >::type m_c
const Kokkos::IntrinsicScalarType< AV >::type m_ab
Kokkos::Details::ArithTraits< typename Kokkos::IntrinsicScalarType< CV >::type > ATS
V_ReciprocalSelf_Functor(const RV &R)
MV_ReciprocalSelf_Functor(const RMV &R)
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)
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType ValueType * y
Kokkos::View< Sacado::UQ::PCE< RS > *, RP... > RV