Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_DerivOrthogPolyExpansion.hpp
Go to the documentation of this file.
1// $Id$
2// $Source$
3// @HEADER
4// ***********************************************************************
5//
6// Stokhos Package
7// Copyright (2009) Sandia Corporation
8//
9// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10// license for use of this work by or on behalf of the U.S. Government.
11//
12// Redistribution and use in source and binary forms, with or without
13// modification, are permitted provided that the following conditions are
14// met:
15//
16// 1. Redistributions of source code must retain the above copyright
17// notice, this list of conditions and the following disclaimer.
18//
19// 2. Redistributions in binary form must reproduce the above copyright
20// notice, this list of conditions and the following disclaimer in the
21// documentation and/or other materials provided with the distribution.
22//
23// 3. Neither the name of the Corporation nor the names of the
24// contributors may be used to endorse or promote products derived from
25// this software without specific prior written permission.
26//
27// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38//
39// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
40//
41// ***********************************************************************
42// @HEADER
43
44#ifndef STOKHOS_DERIVORTHOGPOLYEXPANSION_HPP
45#define STOKHOS_DERIVORTHOGPOLYEXPANSION_HPP
46
49
50#include "Teuchos_RCP.hpp"
51#include "Teuchos_Array.hpp"
52#include "Teuchos_SerialDenseMatrix.hpp"
53#include "Teuchos_SerialDenseVector.hpp"
54#include "Teuchos_LAPACK.hpp"
55
56namespace Stokhos {
57
59 template <typename ordinal_type, typename value_type>
60 class DerivOrthogPolyExpansion : public OrthogPolyExpansion<ordinal_type, value_type> {
61 public:
62
64
67 const Teuchos::RCP<const DerivBasis<ordinal_type, value_type> >& basis,
68 const Teuchos::RCP<const Teuchos::SerialDenseMatrix<ordinal_type, value_type> >& Bij,
70 const Teuchos::RCP<const Stokhos::Dense3Tensor<ordinal_type, value_type> >& Dijk);
71
74
76 ordinal_type size() const { return sz; }
77
79 Teuchos::RCP<const OrthogPolyBasis<ordinal_type, value_type> >
80 getBasis() const {return basis; }
81
83 virtual Teuchos::RCP<const Sparse3Tensor<ordinal_type, value_type> >
84 getTripleProduct() const { return Cijk; }
85
86 // Operations
87 void unaryMinus(
88 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
89 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
90
91 void plusEqual(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
92 const value_type& x);
93 void minusEqual(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
94 const value_type& x);
95 void timesEqual(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
96 const value_type& x);
97 void divideEqual(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
98 const value_type& x);
99
100 void plusEqual(
101 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
102 const OrthogPolyApprox<ordinal_type, value_type, node_type>& x);
103 void minusEqual(
104 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
105 const OrthogPolyApprox<ordinal_type, value_type, node_type>& x);
106 void timesEqual(
107 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
108 const OrthogPolyApprox<ordinal_type, value_type, node_type>& x);
109 void divideEqual(
110 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
111 const OrthogPolyApprox<ordinal_type, value_type, node_type>& x);
112
113 void plus(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
114 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
115 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
116 void plus(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
117 const value_type& a,
118 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
119 void plus(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
120 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
121 const value_type& b);
122 void minus(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
123 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
124 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
125 void minus(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
126 const value_type& a,
127 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
128 void minus(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
129 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
130 const value_type& b);
131 void times(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
132 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
133 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
134 void times(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
135 const value_type& a,
136 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
137 void times(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
138 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
139 const value_type& b);
140 void divide(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
141 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
142 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
143 void divide(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
144 const value_type& a,
145 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
146 void divide(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
147 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
148 const value_type& b);
149
150 void exp(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
151 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
152 void log(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
153 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
154 void log10(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
155 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
156 void sqrt(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
157 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
158 void cbrt(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
159 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
160 void pow(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
161 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
162 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
163 void pow(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
164 const value_type& a,
165 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
166 void pow(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
167 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
168 const value_type& b);
169 void sincos(OrthogPolyApprox<ordinal_type, value_type, node_type>& s,
170 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
171 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
172 void cos(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
173 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
174 void sin(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
175 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
176 void tan(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
177 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
178 void sinhcosh(OrthogPolyApprox<ordinal_type, value_type, node_type>& s,
179 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
180 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
181 void cosh(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
182 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
183 void sinh(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
184 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
185 void tanh(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
186 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
187 template <typename OpT>
188 void quad(const OpT& quad_func,
189 OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
190 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
191 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
192 void acos(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
193 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
194 void asin(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
195 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
196 void atan(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
197 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
198// void atan2(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
199// const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
200// const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
201// void atan2(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
202// const T& a,
203// const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
204// void atan2(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
205// const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
206// const T& b);
207 void acosh(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
208 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
209 void asinh(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
210 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
211 void atanh(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
212 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
213 void abs(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
214 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
215 void fabs(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
216 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
217 void max(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
218 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
219 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
220 void max(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
221 const value_type& a,
222 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
223 void max(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
224 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
225 const value_type& b);
226 void min(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
227 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
228 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
229 void min(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
230 const value_type& a,
231 const OrthogPolyApprox<ordinal_type, value_type, node_type>& b);
232 void min(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
233 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
234 const value_type& b);
235 void derivative(OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
236 const OrthogPolyApprox<ordinal_type, value_type, node_type>& a);
237
238 private:
239
240 // Prohibit copying
242
243 // Prohibit Assignment
245
246 protected:
247
249 Teuchos::RCP< const Stokhos::DerivBasis<ordinal_type, value_type> > basis;
250
252 Teuchos::RCP<const Teuchos::SerialDenseMatrix<ordinal_type, value_type> > Bij;
253
255 Teuchos::RCP<const Stokhos::Sparse3Tensor<ordinal_type, value_type> > Cijk;
256
258 Teuchos::RCP<const Stokhos::Dense3Tensor<ordinal_type, value_type> > Dijk;
259
261 ordinal_type sz;
262
264 Teuchos::SerialDenseMatrix<ordinal_type, value_type> A;
265
267 Teuchos::SerialDenseMatrix<ordinal_type, value_type> B;
268
270 Teuchos::Array<ordinal_type> piv;
271
274
275 protected:
276
278 ordinal_type solve(ordinal_type s, ordinal_type nrhs);
279
281 value_type operator() (const value_type& a) const {
282 return std::acos(a);
283 }
284 };
285
287 value_type operator() (const value_type& a) const {
288 return std::asin(a);
289 }
290 };
291
293 value_type operator() (const value_type& a) const {
294 return std::atan(a);
295 }
296 };
297
299 value_type operator() (const value_type & a) const {
300 return std::log(a+std::sqrt(a*a-value_type(1.0)));
301 }
302 };
303
305 value_type operator() (const value_type& a) const {
306 return std::log(a+std::sqrt(a*a+value_type(1.0)));
307 }
308 };
309
311 value_type operator() (const value_type& a) const {
312 return 0.5*std::log((value_type(1.0)+a)/(value_type(1.0)-a));
313 }
314 };
315
316 }; // class DerivOrthogPolyExpansion
317
318} // namespace Stokhos
319
321
322#endif // STOKHOS_DERIVORTHOGPOLYEXPANSION_HPP
Data structure storing a dense 3-tensor C(i,j,k).
Othogonal polynomial expansions based on derivative calculations.
Teuchos::SerialDenseMatrix< ordinal_type, value_type > B
RHS.
ordinal_type size() const
Get expansion size.
void tan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void minus(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void cbrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::SerialDenseMatrix< ordinal_type, value_type > A
Matrix.
void times(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void exp(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const Stokhos::DerivBasis< ordinal_type, value_type > > basis
Basis.
DerivOrthogPolyExpansion(const DerivOrthogPolyExpansion &)
void abs(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const Stokhos::Dense3Tensor< ordinal_type, value_type > > Dijk
Derivative Triple-product tensor.
void quad(const OpT &quad_func, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void cosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void max(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void unaryMinus(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void plusEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void asin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > Cijk
Triple-product tensor.
void sinhcosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &s, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void atan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void cos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void acos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void atanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void derivative(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void divide(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void minusEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void timesEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void min(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void log10(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void pow(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void sin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
ordinal_type solve(ordinal_type s, ordinal_type nrhs)
Solve linear system.
void sinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
DerivOrthogPolyExpansion(const Teuchos::RCP< const DerivBasis< ordinal_type, value_type > > &basis, const Teuchos::RCP< const Teuchos::SerialDenseMatrix< ordinal_type, value_type > > &Bij, const Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > &Cijk, const Teuchos::RCP< const Stokhos::Dense3Tensor< ordinal_type, value_type > > &Dijk)
Constructor.
void plus(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a, const OrthogPolyApprox< ordinal_type, value_type, node_type > &b)
void divideEqual(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const value_type &x)
void fabs(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > getBasis() const
Get basis.
void asinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::Array< ordinal_type > piv
Pivot array.
virtual Teuchos::RCP< const Sparse3Tensor< ordinal_type, value_type > > getTripleProduct() const
Get triple product.
void acosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void sqrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Teuchos::RCP< const Teuchos::SerialDenseMatrix< ordinal_type, value_type > > Bij
Derivative double-product tensor.
void tanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Stokhos::StandardStorage< ordinal_type, value_type > node_type
Teuchos::LAPACK< ordinal_type, value_type > lapack
LAPACK wrappers.
DerivOrthogPolyExpansion & operator=(const DerivOrthogPolyExpansion &b)
void log(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void sincos(OrthogPolyApprox< ordinal_type, value_type, node_type > &s, OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Abstract base class for orthogonal polynomial-based expansions.
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
Specialization for Sacado::UQ::PCE< Storage<...> >
Top-level namespace for Stokhos classes and functions.