Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_AlgebraicOrthogPolyExpansionImp.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 #include "Teuchos_Assert.hpp"
43 
44 template <typename ordinal_type, typename value_type>
49  const Teuchos::RCP<Teuchos::ParameterList>& params_) :
50  OrthogPolyExpansionBase<ordinal_type, value_type, node_type>(basis_, Cijk_, params_)
51 {
52 }
53 
54 template <typename ordinal_type, typename value_type>
55 void
59 {
60  if (a.size() == 1) {
61  if (c.size() != 1)
62  c.resize(1);
63  c[0] = std::exp(a[0]);
64  }
65  else
66  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
67  "Stokhos::AlgebraicOrthogPolyExpansion::exp()"
68  << ": Method not implemented!");
69 
70 }
71 
72 template <typename ordinal_type, typename value_type>
73 void
77 {
78  if (a.size() == 1) {
79  if (c.size() != 1)
80  c.resize(1);
81  c[0] = std::log(a[0]);
82  }
83  else
84  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
85  "Stokhos::AlgebraicOrthogPolyExpansion::log()"
86  << ": Method not implemented!");
87 }
88 
89 template <typename ordinal_type, typename value_type>
90 void
94 {
95  if (a.size() == 1) {
96  if (c.size() != 1)
97  c.resize(1);
98  c[0] = std::log10(a[0]);
99  }
100  else
101  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
102  "Stokhos::AlgebraicOrthogPolyExpansion::log10()"
103  << ": Method not implemented!");
104 }
105 
106 template <typename ordinal_type, typename value_type>
107 void
111 {
112  if (a.size() == 1) {
113  if (c.size() != 1)
114  c.resize(1);
115  c[0] = std::sqrt(a[0]);
116  }
117  else
118  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
119  "Stokhos::AlgebraicOrthogPolyExpansion::sqrt()"
120  << ": Method not implemented!");
121 }
122 
123 template <typename ordinal_type, typename value_type>
124 void
128 {
129  if (a.size() == 1) {
130  if (c.size() != 1)
131  c.resize(1);
132  c[0] = std::cbrt(a[0]);
133  }
134  else
135  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
136  "Stokhos::AlgebraicOrthogPolyExpansion::cbrt()"
137  << ": Method not implemented!");
138 }
139 
140 template <typename ordinal_type, typename value_type>
141 void
146 {
147  if (a.size() == 1 && b.size() == 1) {
148  if (c.size() != 1)
149  c.resize(1);
150  c[0] = std::pow(a[0], b[0]);
151  }
152  else
153  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
154  "Stokhos::AlgebraicOrthogPolyExpansion::pow()"
155  << ": Method not implemented!");
156 }
157 
158 template <typename ordinal_type, typename value_type>
159 void
162  const value_type& a,
164 {
165  if (b.size() == 1) {
166  if (c.size() != 1)
167  c.resize(1);
168  c[0] = std::pow(a, b[0]);
169  }
170  else
171  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
172  "Stokhos::AlgebraicOrthogPolyExpansion::pow()"
173  << ": Method not implemented!");
174 }
175 
176 template <typename ordinal_type, typename value_type>
177 void
181  const value_type& b)
182 {
183  if (a.size() == 1) {
184  if (c.size() != 1)
185  c.resize(1);
186  c[0] = std::pow(a[0], b);
187  }
188  else
189  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
190  "Stokhos::AlgebraicOrthogPolyExpansion::pow()"
191  << ": Method not implemented!");
192 }
193 
194 template <typename ordinal_type, typename value_type>
195 void
199 {
200  if (a.size() == 1) {
201  if (s.size() != 1)
202  s.resize(1);
203  s[0] = std::sin(a[0]);
204  }
205  else
206  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
207  "Stokhos::AlgebraicOrthogPolyExpansion::sin()"
208  << ": Method not implemented!");
209 }
210 
211 template <typename ordinal_type, typename value_type>
212 void
216 {
217  if (a.size() == 1) {
218  if (c.size() != 1)
219  c.resize(1);
220  c[0] = std::cos(a[0]);
221  }
222  else
223  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
224  "Stokhos::AlgebraicOrthogPolyExpansion::cos()"
225  << ": Method not implemented!");
226 }
227 
228 template <typename ordinal_type, typename value_type>
229 void
233 {
234  if (a.size() == 1) {
235  if (t.size() != 1)
236  t.resize(1);
237  t[0] = std::tan(a[0]);
238  }
239  else
240  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
241  "Stokhos::AlgebraicOrthogPolyExpansion::tan()"
242  << ": Method not implemented!");
243 }
244 
245 template <typename ordinal_type, typename value_type>
246 void
250 {
251  if (a.size() == 1) {
252  if (s.size() != 1)
253  s.resize(1);
254  s[0] = std::sinh(a[0]);
255  }
256  else
257  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
258  "Stokhos::AlgebraicOrthogPolyExpansion::sinh()"
259  << ": Method not implemented!");
260 }
261 
262 template <typename ordinal_type, typename value_type>
263 void
267 {
268  if (a.size() == 1) {
269  if (c.size() != 1)
270  c.resize(1);
271  c[0] = std::cosh(a[0]);
272  }
273  else
274  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
275  "Stokhos::AlgebraicOrthogPolyExpansion::cosh()"
276  << ": Method not implemented!");
277 }
278 
279 template <typename ordinal_type, typename value_type>
280 void
284 {
285  if (a.size() == 1) {
286  if (t.size() != 1)
287  t.resize(1);
288  t[0] = std::tanh(a[0]);
289  }
290  else
291  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
292  "Stokhos::AlgebraicOrthogPolyExpansion::tanh()"
293  << ": Method not implemented!");
294 }
295 
296 template <typename ordinal_type, typename value_type>
297 void
301 {
302  if (a.size() == 1) {
303  if (c.size() != 1)
304  c.resize(1);
305  c[0] = std::acos(a[0]);
306  }
307  else
308  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
309  "Stokhos::AlgebraicOrthogPolyExpansion::acos()"
310  << ": Method not implemented!");
311 }
312 
313 template <typename ordinal_type, typename value_type>
314 void
318 {
319  if (a.size() == 1) {
320  if (c.size() != 1)
321  c.resize(1);
322  c[0] = std::asin(a[0]);
323  }
324  else
325  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
326  "Stokhos::AlgebraicOrthogPolyExpansion::asin()"
327  << ": Method not implemented!");
328 }
329 
330 template <typename ordinal_type, typename value_type>
331 void
335 {
336  if (a.size() == 1) {
337  if (c.size() != 1)
338  c.resize(1);
339  c[0] = std::atan(a[0]);
340  }
341  else
342  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
343  "Stokhos::AlgebraicOrthogPolyExpansion::atan()"
344  << ": Method not implemented!");
345 }
346 
347 template <typename ordinal_type, typename value_type>
348 void
353 {
354  if (a.size() == 1 && b.size() == 1) {
355  if (c.size() != 1)
356  c.resize(1);
357  c[0] = std::atan2(a[0], b[0]);
358  }
359  else
360  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
361  "Stokhos::AlgebraicOrthogPolyExpansion::atan2()"
362  << ": Method not implemented!");
363 }
364 
365 template <typename ordinal_type, typename value_type>
366 void
369  const value_type& a,
371 {
372  if (b.size() == 1) {
373  if (c.size() != 1)
374  c.resize(1);
375  c[0] = std::atan2(a, b[0]);
376  }
377  else
378  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
379  "Stokhos::AlgebraicOrthogPolyExpansion::atan2()"
380  << ": Method not implemented!");
381 }
382 
383 template <typename ordinal_type, typename value_type>
384 void
388  const value_type& b)
389 {
390  if (a.size() == 1) {
391  if (c.size() != 1)
392  c.resize(1);
393  c[0] = std::atan2(a[0], b);
394  }
395  else
396  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
397  "Stokhos::AlgebraicOrthogPolyExpansion::atan2()"
398  << ": Method not implemented!");
399 }
400 
401 template <typename ordinal_type, typename value_type>
402 void
406 {
407  if (a.size() == 1) {
408  if (c.size() != 1)
409  c.resize(1);
410  c[0] = std::log(a[0]+std::sqrt(a[0]*a[0]-value_type(1.0)));
411  }
412  else
413  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
414  "Stokhos::AlgebraicOrthogPolyExpansion::acosh()"
415  << ": Method not implemented!");
416 }
417 
418 template <typename ordinal_type, typename value_type>
419 void
423 {
424  if (a.size() == 1) {
425  if (c.size() != 1)
426  c.resize(1);
427  c[0] = std::log(a[0]+std::sqrt(a[0]*a[0]+value_type(1.0)));
428  }
429  else
430  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
431  "Stokhos::AlgebraicOrthogPolyExpansion::asinh()"
432  << ": Method not implemented!");
433 }
434 
435 template <typename ordinal_type, typename value_type>
436 void
440 {
441  if (a.size() == 1) {
442  if (c.size() != 1)
443  c.resize(1);
444  c[0] = 0.5*std::log((value_type(1.0)+a[0])/(value_type(1.0)-a[0]));
445  }
446  else
447  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
448  "Stokhos::AlgebraicOrthogPolyExpansion::atanh()"
449  << ": Method not implemented!");
450 }
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > sinh(const PCE< Storage > &a)
void resize(ordinal_type sz)
Resize coefficient array (coefficients are preserved)
void log10(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
void asinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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)
AlgebraicOrthogPolyExpansion(const Teuchos::RCP< const OrthogPolyBasis< ordinal_type, value_type > > &basis, const Teuchos::RCP< const Stokhos::Sparse3Tensor< ordinal_type, value_type > > &Cijk, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor.
Base class for consolidating common expansion implementations.
void asin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > tanh(const PCE< Storage > &a)
void exp(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cbrt(const PCE< Storage > &a)
void acos(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > acos(const PCE< Storage > &a)
atan2(expr1.val(), expr2.val())
void tanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Abstract base class for multivariate orthogonal polynomials.
void atan2(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 sqrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cosh(const PCE< Storage > &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 cosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > atan(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
void log(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
Class to store coefficients of a projection onto an orthogonal polynomial basis.
void sin(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void tan(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
void atanh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
ordinal_type size() const
Return size.
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
void cbrt(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > asin(const PCE< Storage > &a)
void acosh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
void sinh(OrthogPolyApprox< ordinal_type, value_type, node_type > &c, const OrthogPolyApprox< ordinal_type, value_type, node_type > &a)
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)