Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_ProductContainerImp.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 template <typename coeff_type>
13  map_(),
14  coeff_()
15 {
16 }
17 
18 template <typename coeff_type>
21  map_(theMap),
22  coeff_(map_->NumMyElements())
23 {
24 }
25 
26 template <typename coeff_type>
29  const typename traits_type::cloner_type& cloner) :
30  map_(theMap),
31  coeff_(map_->NumMyElements())
32 {
34  for (ordinal_type i=0; i<sz; i++)
35  coeff_[i] = cloner.clone(i);
36 }
37 
38 template <typename coeff_type>
41  map_(v.map_),
42  coeff_(v.coeff_)
43 {
44 }
45 
46 template <typename coeff_type>
49 {
50 }
51 
52 template <typename coeff_type>
56 {
57  if (this != &v) {
58  map_ = v.map_;
59  coeff_ = v.coeff_;
60  }
61  return *this;
62 }
63 
64 template <typename coeff_type>
65 void
68 {
69  map_ = theMap;
70  ordinal_type sz = map_->NumMyElements();
71  coeff_.resize(sz);
72 }
73 
74 template <typename coeff_type>
75 void
78  const typename traits_type::cloner_type& cloner)
79 {
80  map_ = theMap;
81  ordinal_type sz = map_->NumMyElements();
82  coeff_.resize(sz);
83  for (ordinal_type i=0; i<sz; i++)
84  coeff_[i] = cloner.clone(i);
85 }
86 
87 template <typename coeff_type>
88 void
91 {
92  map_ = theMap;
93  coeff_.resize(map_->NumMyElements());
94 }
95 
96 template <typename coeff_type>
97 void
100 {
101  coeff_.reserve(sz);
102 }
103 
104 template <typename coeff_type>
107 size() const
108 {
109  return coeff_.size();
110 }
111 
112 template <typename coeff_type>
115 map() const
116 {
117  return map_;
118 }
119 
120 template <typename coeff_type>
124 {
125  return coeff_;
126 }
127 
128 template <typename coeff_type>
132 {
133  return coeff_;
134 }
135 
136 template <typename coeff_type>
140 {
141  return coeff_[i];
142 }
143 
144 template <typename coeff_type>
148 {
149  return coeff_[i];
150 }
151 
152 template <typename coeff_type>
153 void
156 {
157  coeff_[i] = c;
158 }
159 
160 template <typename coeff_type>
161 coeff_type&
164 {
165  return *(coeff_[i]);
166 }
167 
168 template <typename coeff_type>
169 const coeff_type&
172 {
173  return *(coeff_[i]);
174 }
175 
176 template <typename coeff_type>
177 bool
179 myGID(int i) const
180 {
181  return map_->MyGID(i);
182 }
183 
184 template <typename coeff_type>
185 void
188 {
189  ordinal_type sz = coeff_.size();
190  for (ordinal_type i=0; i<sz; i++)
191  traits_type::init(*(coeff_[i]), val);
192 }
193 
194 template <typename coeff_type>
195 std::ostream&
197 print(std::ostream& os) const
198 {
200  ordinal_type sz = coeff_.size();
201  os << "Stokhos::ProductContainer of global size " << map_->NumGlobalElements()
202  << ", local size " << sz << ":" << std::endl;
203  for (ordinal_type i=0; i<sz; i++) {
204  os << "Term " << map_->GID(i) << ":" << std::endl;
205  traits_type::print(os, *(coeff_[i]));
206  }
207 
208  return os;
209 }
Teuchos::RCP< const Epetra_BlockMap > map() const
Return container map.
void setCoeffPtr(ordinal_type i, const Teuchos::RCP< coeff_type > &c)
Set coefficient i to c.
bool myGID(int i) const
Return whether global index i resides on this processor.
ProductContainer & operator=(const ProductContainer &)
Assignment.
void init(const value_type &val)
Initialize coefficients.
coeff_type & operator[](ordinal_type i)
Array access.
int NumMyElements() const
Teuchos::RCP< const Epetra_BlockMap > map_
Container map.
const Teuchos::Array< Teuchos::RCP< coeff_type > > & getCoefficients() const
Return array of coefficients.
void reset(const Teuchos::RCP< const Epetra_BlockMap > &map)
Resize to new map map.
Teuchos::Array< Teuchos::RCP< coeff_type > > coeff_
Array of polynomial coefficients.
Teuchos::RCP< coeff_type > getCoeffPtr(ordinal_type i)
Return ref-count pointer to coefficient i.
A product (in the mathematical sense) container class whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
traits_type::ordinal_type ordinal_type
Typename of ordinals.
expr val()
size_type size() const
std::ostream & print(std::ostream &os) const
Print polynomial.
traits_type::value_type value_type
Typename of values.
void reserve(ordinal_type sz)
Reserve space for a size sz container.
ordinal_type size() const
Return size.
void resize(const Teuchos::RCP< const Epetra_BlockMap > &map)
Resize to map map.