Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_StandardStorage.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_STANDARD_STORAGE_HPP
11 #define STOKHOS_STANDARD_STORAGE_HPP
12 
13 #include "Teuchos_Array.hpp"
14 #include <algorithm>
15 
16 namespace Stokhos {
17 
18  template <typename ordinal_type, typename value_type>
20  public:
21 
23  typedef const value_type& const_reference;
24  typedef value_type* pointer;
25  typedef const value_type* const_pointer;
26 
28  template <typename ord_t, typename val_t>
29  struct apply {
31  };
32 
35  const value_type& x = value_type(0.0)) :
36  coeff_(sz, x) {}
37 
40 
42  void init(const_reference v) {
43  std::fill(coeff_.begin(), coeff_.end(), v);
44  }
45 
47  void init(const_pointer v, const ordinal_type& sz = 0) {
48  if (sz == 0)
49  std::copy(v, v+coeff_.size(), coeff_.begin());
50  else
51  std::copy(v, v+sz, coeff_.begin());
52  }
53 
55  void load(pointer v) {
56  std::copy(coeff_.begin(), coeff_.end(), v);
57  }
58 
60  void resize(const ordinal_type& sz) { coeff_.resize(sz); }
61 
63  ordinal_type size() const { return coeff_.size(); }
64 
67  return coeff_[i];
68  }
69 
72  return coeff_[i];
73  }
74 
76  const_pointer coeff() const { return coeff_.getRawPtr(); }
77 
79  pointer coeff() { return coeff_.getRawPtr(); }
80 
81  private:
82 
85 
86  };
87 
88 }
89 
90 #endif // STOKHOS_STANDARD_STORAGE_HPP
void init(const_pointer v, const ordinal_type &sz=0)
Initialize values to an array of values.
StandardStorage(const ordinal_type &sz, const value_type &x=value_type(0.0))
Constructor.
const_pointer coeff() const
Get coefficients.
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)
pointer coeff()
Get coefficients.
StandardStorage< ord_t, val_t > type
void load(pointer v)
Load values to an array of values.
const_reference operator[](const ordinal_type &i) const
Coefficient access (avoid if possible)
void resize(size_type new_size, const value_type &x=value_type())
Teuchos::Array< value_type > coeff_
Coefficient values.
iterator end()
void init(const_reference v)
Initialize values to a constant value.
size_type size() const
void resize(const ordinal_type &sz)
Resize to new size (values are preserved)
iterator begin()
Turn StandardStorage into a meta-function class usable with mpl::apply.
ordinal_type size() const
Return size.