Debian Codegraph @

packages/stokhos/src/sacado/kokkos/pce/algorithms/Kokkos_Random_UQ_PCE.hpp

raw
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> > {
28 typedef Sacado::UQ::PCE<Storage> Scalar;
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 */