Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_StaticStandardStorage.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 STOKHOS_STATIC_STANDARD_STORAGE_HPP
11 #define STOKHOS_STATIC_STANDARD_STORAGE_HPP
12 
13 #include "Sacado_StaticArrayTraits.hpp"
14 #include <algorithm>
15 
16 namespace Stokhos {
17 
19  template <typename ordinal_type, typename value_type, int Num>
21  public:
22 
24  typedef const value_type& const_reference;
25  typedef value_type* pointer;
26  typedef const value_type* const_pointer;
27  typedef Sacado::ss_array<value_type> ss;
28 
30  template <typename ord_t, typename val_t>
31  struct apply {
33  };
34 
37  const value_type& x = value_type(0.0)) : sz(sz_) {
38  std::fill(coeff_, coeff_+sz, x);
39  }
40 
43  ss::copy(s.coeff_, coeff_, sz);
44  }
45 
48 
51  sz = s.sz;
52  ss::copy(s.coeff_, coeff_, sz);
53  return *this;
54  }
55 
57  void init(const_reference v) {
58  std::fill(coeff_, coeff_+sz, v);
59  }
60 
62  void init(const_pointer v, const ordinal_type& sz_ = 0) {
63  if (sz_ == 0)
64  ss::copy(v, coeff_, sz);
65  else
66  ss::copy(v, coeff_, sz_);
67  }
68 
70  void load(pointer v) {
71  ss::copy(coeff_, v, sz);
72  }
73 
75  void resize(const ordinal_type& sz_) {
76  if (sz_ > sz)
77  std::fill(coeff_+sz, coeff_+sz_, value_type(0.0));
78  sz = sz_;
79  }
80 
82  ordinal_type size() const { return sz; }
83 
86  return coeff_[i];
87  }
88 
90  reference operator[] (const ordinal_type& i) { return coeff_[i]; }
91 
93  const_pointer coeff() const { return coeff_; }
94 
96  pointer coeff() { return coeff_; }
97 
98  private:
99 
102 
105 
106  };
107 
108 }
109 
110 #endif // STOKHOS_STANDARD_STORAGE_HPP
const_reference operator[](const ordinal_type &i) const
Coefficient access (avoid if possible)
Turn StaticStandardStorage into a meta-function class usable with mpl::apply.
StaticStandardStorage & operator=(const StaticStandardStorage &s)
Assignment operator.
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)
Statically allocated storage class.
void resize(const ordinal_type &sz_)
Resize to new size (values are preserved)
const_pointer coeff() const
Get coefficients.
void load(pointer v)
Load values to an array of values.
void init(const_pointer v, const ordinal_type &sz_=0)
Initialize values to an array of values.
value_type coeff_[Num]
Coefficient values.
StaticStandardStorage(const StaticStandardStorage &s)
Copy constructor.
void init(const_reference v)
Initialize values to a constant value.
StaticStandardStorage< ord_t, val_t, Num > type
StaticStandardStorage(const ordinal_type &sz_, const value_type &x=value_type(0.0))
Constructor.
ordinal_type size() const
Return size.