Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
epetra
Stokhos_ProductContainerImp.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Stokhos Package
5
// Copyright (2009) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
template
<
typename
coeff_type>
43
Stokhos::ProductContainer<coeff_type>::
44
ProductContainer
() :
45
map_
(),
46
coeff_
()
47
{
48
}
49
50
template
<
typename
coeff_type>
51
Stokhos::ProductContainer<coeff_type>::
52
ProductContainer
(
const
Teuchos::RCP<const Epetra_BlockMap>& theMap) :
53
map_
(theMap),
54
coeff_
(
map_
->NumMyElements())
55
{
56
}
57
58
template
<
typename
coeff_type>
59
Stokhos::ProductContainer<coeff_type>::
60
ProductContainer
(
const
Teuchos::RCP<const Epetra_BlockMap>& theMap,
61
const
typename
traits_type::cloner_type& cloner) :
62
map_
(theMap),
63
coeff_
(
map_
->NumMyElements())
64
{
65
ordinal_type
sz =
map_
->NumMyElements();
66
for
(
ordinal_type
i=0; i<sz; i++)
67
coeff_
[i] = cloner.clone(i);
68
}
69
70
template
<
typename
coeff_type>
71
Stokhos::ProductContainer<coeff_type>::
72
ProductContainer
(
const
Stokhos::ProductContainer<coeff_type>
& v) :
73
map_
(v.
map_
),
74
coeff_
(v.
coeff_
)
75
{
76
}
77
78
template
<
typename
coeff_type>
79
Stokhos::ProductContainer<coeff_type>::
80
~ProductContainer
()
81
{
82
}
83
84
template
<
typename
coeff_type>
85
Stokhos::ProductContainer<coeff_type>
&
86
Stokhos::ProductContainer<coeff_type>::
87
operator=
(
const
Stokhos::ProductContainer<coeff_type>
& v)
88
{
89
if
(
this
!= &v) {
90
map_
= v.
map_
;
91
coeff_
= v.
coeff_
;
92
}
93
return
*
this
;
94
}
95
96
template
<
typename
coeff_type>
97
void
98
Stokhos::ProductContainer<coeff_type>::
99
reset
(
const
Teuchos::RCP<const Epetra_BlockMap>& theMap)
100
{
101
map_
= theMap;
102
ordinal_type
sz =
map_
->NumMyElements();
103
coeff_
.resize(sz);
104
}
105
106
template
<
typename
coeff_type>
107
void
108
Stokhos::ProductContainer<coeff_type>::
109
reset
(
const
Teuchos::RCP<const Epetra_BlockMap>& theMap,
110
const
typename
traits_type::cloner_type& cloner)
111
{
112
map_
= theMap;
113
ordinal_type
sz =
map_
->NumMyElements();
114
coeff_
.resize(sz);
115
for
(
ordinal_type
i=0; i<sz; i++)
116
coeff_
[i] = cloner.clone(i);
117
}
118
119
template
<
typename
coeff_type>
120
void
121
Stokhos::ProductContainer<coeff_type>::
122
resize
(
const
Teuchos::RCP<const Epetra_BlockMap>& theMap)
123
{
124
map_
= theMap;
125
coeff_
.resize(
map_
->NumMyElements());
126
}
127
128
template
<
typename
coeff_type>
129
void
130
Stokhos::ProductContainer<coeff_type>::
131
reserve
(
ordinal_type
sz)
132
{
133
coeff_
.reserve(sz);
134
}
135
136
template
<
typename
coeff_type>
137
typename
Stokhos::ProductContainer<coeff_type>::ordinal_type
138
Stokhos::ProductContainer<coeff_type>::
139
size
()
const
140
{
141
return
coeff_
.size();
142
}
143
144
template
<
typename
coeff_type>
145
Teuchos::RCP<const Epetra_BlockMap>
146
Stokhos::ProductContainer<coeff_type>::
147
map
()
const
148
{
149
return
map_
;
150
}
151
152
template
<
typename
coeff_type>
153
const
Teuchos::Array<Teuchos::RCP<coeff_type> >&
154
Stokhos::ProductContainer<coeff_type>::
155
getCoefficients
()
const
156
{
157
return
coeff_
;
158
}
159
160
template
<
typename
coeff_type>
161
Teuchos::Array<Teuchos::RCP<coeff_type> >&
162
Stokhos::ProductContainer<coeff_type>::
163
getCoefficients
()
164
{
165
return
coeff_
;
166
}
167
168
template
<
typename
coeff_type>
169
Teuchos::RCP<coeff_type>
170
Stokhos::ProductContainer<coeff_type>::
171
getCoeffPtr
(
ordinal_type
i)
172
{
173
return
coeff_
[i];
174
}
175
176
template
<
typename
coeff_type>
177
Teuchos::RCP<const coeff_type>
178
Stokhos::ProductContainer<coeff_type>::
179
getCoeffPtr
(
ordinal_type
i)
const
180
{
181
return
coeff_
[i];
182
}
183
184
template
<
typename
coeff_type>
185
void
186
Stokhos::ProductContainer<coeff_type>::
187
setCoeffPtr
(
ordinal_type
i,
const
Teuchos::RCP<coeff_type>& c)
188
{
189
coeff_
[i] = c;
190
}
191
192
template
<
typename
coeff_type>
193
coeff_type&
194
Stokhos::ProductContainer<coeff_type>::
195
operator[]
(
ordinal_type
i)
196
{
197
return
*(
coeff_
[i]);
198
}
199
200
template
<
typename
coeff_type>
201
const
coeff_type&
202
Stokhos::ProductContainer<coeff_type>::
203
operator[]
(
ordinal_type
i)
const
204
{
205
return
*(
coeff_
[i]);
206
}
207
208
template
<
typename
coeff_type>
209
bool
210
Stokhos::ProductContainer<coeff_type>::
211
myGID
(
int
i)
const
212
{
213
return
map_
->MyGID(i);
214
}
215
216
template
<
typename
coeff_type>
217
void
218
Stokhos::ProductContainer<coeff_type>::
219
init
(
const
value_type
&
val
)
220
{
221
ordinal_type
sz =
coeff_
.size();
222
for
(
ordinal_type
i=0; i<sz; i++)
223
traits_type::init(*(
coeff_
[i]),
val
);
224
}
225
226
template
<
typename
coeff_type>
227
std::ostream&
228
Stokhos::ProductContainer<coeff_type>::
229
print
(std::ostream& os)
const
230
{
231
Teuchos::Array<ordinal_type> trm;
232
ordinal_type
sz =
coeff_
.size();
233
os <<
"Stokhos::ProductContainer of global size "
<<
map_
->NumGlobalElements()
234
<<
", local size "
<< sz <<
":"
<< std::endl;
235
for
(
ordinal_type
i=0; i<sz; i++) {
236
os <<
"Term "
<<
map_
->GID(i) <<
":"
<< std::endl;
237
traits_type::print(os, *(
coeff_
[i]));
238
}
239
240
return
os;
241
}
val
expr val()
Stokhos::ProductContainer
A product (in the mathematical sense) container class whose coefficients are vectors,...
Definition
Stokhos_ProductContainer.hpp:61
Stokhos::ProductContainer::ProductContainer
ProductContainer()
Default constructor.
Definition
Stokhos_ProductContainerImp.hpp:44
Stokhos::ProductContainer::value_type
traits_type::value_type value_type
Typename of values.
Definition
Stokhos_ProductContainer.hpp:68
Stokhos::ProductContainer::ordinal_type
traits_type::ordinal_type ordinal_type
Typename of ordinals.
Definition
Stokhos_ProductContainer.hpp:71
Stokhos::ProductContainer::map
Teuchos::RCP< const Epetra_BlockMap > map() const
Return container map.
Definition
Stokhos_ProductContainerImp.hpp:147
Stokhos::ProductContainer::coeff_
Teuchos::Array< Teuchos::RCP< coeff_type > > coeff_
Array of polynomial coefficients.
Definition
Stokhos_ProductContainer.hpp:179
Stokhos::ProductContainer::reserve
void reserve(ordinal_type sz)
Reserve space for a size sz container.
Definition
Stokhos_ProductContainerImp.hpp:131
Stokhos::ProductContainer::getCoefficients
const Teuchos::Array< Teuchos::RCP< coeff_type > > & getCoefficients() const
Return array of coefficients.
Definition
Stokhos_ProductContainerImp.hpp:155
Stokhos::ProductContainer::reset
void reset(const Teuchos::RCP< const Epetra_BlockMap > &map)
Resize to new map map.
Definition
Stokhos_ProductContainerImp.hpp:99
Stokhos::ProductContainer::print
std::ostream & print(std::ostream &os) const
Print polynomial.
Definition
Stokhos_ProductContainerImp.hpp:229
Stokhos::ProductContainer::getCoeffPtr
Teuchos::RCP< coeff_type > getCoeffPtr(ordinal_type i)
Return ref-count pointer to coefficient i.
Definition
Stokhos_ProductContainerImp.hpp:171
Stokhos::ProductContainer::init
void init(const value_type &val)
Initialize coefficients.
Definition
Stokhos_ProductContainerImp.hpp:219
Stokhos::ProductContainer::~ProductContainer
virtual ~ProductContainer()
Destructor.
Definition
Stokhos_ProductContainerImp.hpp:80
Stokhos::ProductContainer::operator=
ProductContainer & operator=(const ProductContainer &)
Assignment.
Definition
Stokhos_ProductContainerImp.hpp:87
Stokhos::ProductContainer::size
ordinal_type size() const
Return size.
Definition
Stokhos_ProductContainerImp.hpp:139
Stokhos::ProductContainer::resize
void resize(const Teuchos::RCP< const Epetra_BlockMap > &map)
Resize to map map.
Definition
Stokhos_ProductContainerImp.hpp:122
Stokhos::ProductContainer::operator[]
coeff_type & operator[](ordinal_type i)
Array access.
Definition
Stokhos_ProductContainerImp.hpp:195
Stokhos::ProductContainer::map_
Teuchos::RCP< const Epetra_BlockMap > map_
Container map.
Definition
Stokhos_ProductContainer.hpp:176
Stokhos::ProductContainer::setCoeffPtr
void setCoeffPtr(ordinal_type i, const Teuchos::RCP< coeff_type > &c)
Set coefficient i to c.
Definition
Stokhos_ProductContainerImp.hpp:187
Stokhos::ProductContainer::myGID
bool myGID(int i) const
Return whether global index i resides on this processor.
Definition
Stokhos_ProductContainerImp.hpp:211
Generated by
1.17.0