Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_EpetraMultiVectorOrthogPoly.cpp
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 
43 
49 {
50 }
51 
55  const Teuchos::RCP<const Epetra_BlockMap>& block_map) :
57  VectorOrthogPoly<Epetra_MultiVector>(basis, block_map),
58  ProductEpetraMultiVector(block_map)
59 {
60 }
61 
65  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
66  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map,
67  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm,
68  int num_vectors) :
70  VectorOrthogPoly<Epetra_MultiVector>(basis, block_map),
71  ProductEpetraMultiVector(block_map, coeff_map, product_comm, num_vectors)
72 {
73 }
74 
78  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
79  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map,
80  const Teuchos::RCP<const Epetra_BlockMap>& product_map,
81  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm,
82  int num_vectors) :
84  VectorOrthogPoly<Epetra_MultiVector>(basis, block_map),
85  ProductEpetraMultiVector(block_map, coeff_map, product_map, product_comm,
86  num_vectors)
87 {
88 }
89 
93  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
94  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map,
95  const Teuchos::RCP<const Epetra_BlockMap>& product_map,
96  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm,
98  const Epetra_MultiVector& block_vector) :
100  VectorOrthogPoly<Epetra_MultiVector>(basis, block_map),
101  ProductEpetraMultiVector(block_map, coeff_map, product_map, product_comm, CV,
102  block_vector)
103 {
104 }
105 
111 {
112 }
113 
116 
121  this->basis_ = v.basis_;
122  return *this;
123 }
124 
125 void
128  const Teuchos::RCP<const Stokhos::OrthogPolyBasis<int, double> >& new_basis,
129  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
130  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map,
131  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm,
132  int num_vectors)
133 {
134  ProductEpetraMultiVector::reset(block_map, coeff_map, product_comm,
135  num_vectors);
136  this->basis_ = new_basis;
137 }
138 
139 void
142  const Teuchos::RCP<const Stokhos::OrthogPolyBasis<int, double> >& new_basis,
143  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
144  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map,
145  const Teuchos::RCP<const Epetra_BlockMap>& product_map,
146  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm,
147  int num_vectors)
148 {
149  ProductEpetraMultiVector::reset(block_map, coeff_map, product_map,
150  product_comm, num_vectors);
151  this->basis_ = new_basis;
152 }
153 
154 void
157 {
158  int lid = this->map_->LID(0);
159  v.Scale(1.0, *(this->coeff_[lid]));
160 }
161 
162 void
165 {
166  const Teuchos::Array<double>& nrm2 = this->basis_->norm_squared();
167  v.PutScalar(0.0);
168  int i_gid;
169  for (int i=1; i<this->size(); i++) {
170  i_gid = this->map_->GID(i);
171  v.Multiply(nrm2[i_gid], *(this->coeff_[i]), *(this->coeff_[i]), 1.0);
172  }
173 }
174 
175 void
178 {
179  computeVariance(v);
180 
181  for (int j=0; j<v.NumVectors(); j++)
182  for (int i=0; i<v.MyLength(); i++)
183  v[j][i] = std::sqrt(v[j][i]);
184 }
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
void computeMean(Epetra_MultiVector &v) const
Compute mean.
EpetraMultiVectorOrthogPoly & operator=(const EpetraMultiVectorOrthogPoly &v)
Assignment.
void computeStandardDeviation(Epetra_MultiVector &v) const
Compute standard deviation.
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &basis, const Teuchos::RCP< const Epetra_BlockMap > &block_map, const Teuchos::RCP< const Epetra_BlockMap > &coeff_map, const Teuchos::RCP< const EpetraExt::MultiComm > &product_comm, int num_vectors)
Reset to a new basis.
ProductEpetraMultiVector & operator=(const ProductEpetraMultiVector &v)
Assignment.
void computeVariance(Epetra_MultiVector &v) const
Compute variance.
void reset(const Teuchos::RCP< const Epetra_BlockMap > &block_map, const Teuchos::RCP< const Epetra_BlockMap > &coeff_map, const Teuchos::RCP< const EpetraExt::MultiComm > &product_comm, int num_vectors)
Reset to a new size.
A container class storing products of Epetra_MultiVector&#39;s.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis_
Basis.
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.
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
Epetra_DataAccess
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.