Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_StaticFixedStandardStorage.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_FIXED_STANDARD_STORAGE_HPP
11 #define STOKHOS_STATIC_FIXED_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)) {
38  std::fill(coeff_, coeff_+Num, x);
39  }
40 
43  ss::copy(s.coeff_, coeff_, Num);
44  }
45 
48 
51  ss::copy(s.coeff_, coeff_, Num);
52  return *this;
53  }
54 
56  void init(const_reference v) {
57  std::fill(coeff_, coeff_+Num, v);
58  }
59 
61  void init(const_pointer v, const ordinal_type& sz_ = 0) {
62  if (sz_ == 0)
63  ss::copy(v, coeff_, Num);
64  else
65  ss::copy(v, coeff_, sz_);
66  }
67 
69  void load(pointer v) {
70  ss::copy(coeff_, v, Num);
71  }
72 
74  void resize(const ordinal_type& sz) {}
75 
77  static ordinal_type size() { return Num; }
78 
81  return coeff_[i];
82  }
83 
85  reference operator[] (const ordinal_type& i) { return coeff_[i]; }
86 
88  const_pointer coeff() const { return coeff_; }
89 
91  pointer coeff() { return coeff_; }
92 
93  private:
94 
97 
98  };
99 
100 }
101 
102 #endif // STOKHOS_STANDARD_STORAGE_HPP
StaticFixedStandardStorage< ord_t, val_t, Num > type
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)
void load(pointer v)
Load values to an array of values.
void resize(const ordinal_type &sz)
Resize to new size (values are preserved)
void init(const_reference v)
Initialize values to a constant value.
StaticFixedStandardStorage(const StaticFixedStandardStorage &s)
Copy constructor.
const_reference operator[](const ordinal_type &i) const
Coefficient access (avoid if possible)
StaticFixedStandardStorage(const ordinal_type &sz, const value_type &x=value_type(0.0))
Constructor.
const_pointer coeff() const
Get coefficients.
Turn StaticFixedStandardStorage into a meta-function class usable with mpl::apply.
StaticFixedStandardStorage & operator=(const StaticFixedStandardStorage &s)
Assignment operator.
void init(const_pointer v, const ordinal_type &sz_=0)
Initialize values to an array of values.