Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Kokkos_Random_UQ_PCE.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef KOKKOS_RANDOM_UQ_PCE_HPP
11 #define KOKKOS_RANDOM_UQ_PCE_HPP
12 
13 #include "Stokhos_ConfigDefs.h"
14 #if defined(HAVE_STOKHOS_KOKKOS)
15 
16 #include "Sacado_UQ_PCE.hpp"
17 #include "Kokkos_View_UQ_PCE.hpp"
18 #include "Kokkos_Random.hpp"
19 
20 //----------------------------------------------------------------------------
21 // Specializations of Kokkos random functions for Sacado::UQ::PCE scalar type
22 //----------------------------------------------------------------------------
23 
24 namespace Kokkos {
25 
26  template<class Generator, class Storage>
27  struct rand<Generator,Sacado::UQ::PCE<Storage> > {
29  typedef typename Scalar::value_type BaseScalar;
30  typedef rand<Generator,BaseScalar> BaseRand;
31 
32  KOKKOS_INLINE_FUNCTION
33  static Scalar max() { return BaseRand::max(); }
34 
35  KOKKOS_INLINE_FUNCTION
36  static Scalar draw(Generator& gen) {
37  return BaseRand::draw(gen);
38  }
39 
40  KOKKOS_INLINE_FUNCTION
41  static Scalar draw(Generator& gen, const Scalar& range) {
42  return BaseRand::draw(gen, range.coeff(0));
43  }
44 
45  KOKKOS_INLINE_FUNCTION
46  static Scalar draw(Generator& gen, const Scalar& start, const Scalar& end) {
47  return BaseRand::draw(gen, start.coeff(0), end.coeff(0));
48  }
49  };
50 
51  template<class S, class ... P, class RandomPool>
52  void fill_random( const View<Sacado::UQ::PCE<S>**,P...>& a,
53  RandomPool g,
54  const Sacado::UQ::PCE<S>& begin,
55  const Sacado::UQ::PCE<S>& end ) {
56  typedef View<Sacado::UQ::PCE<S>**,P...> Vector;
57  typename Kokkos::FlatArrayType<Vector>::type a_flat = a;
58  fill_random( a_flat, g, begin.fastAccessCoeff(0), end.fastAccessCoeff(0) );
59  }
60 
61 }
62 
63 #endif
64 
65 #endif /* #ifndef KOKKOS_RANDOM_UQ_PCE_HPP */
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
ScalarType g(const Teuchos::Array< ScalarType > &x, const ScalarType &y)