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 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Teuchos_Assert.hpp"
11 
12 template <typename ordinal_type, typename value_type>
17  const Teuchos::RCP<Teuchos::ParameterList>& params_) :
18  OrthogPolyExpansionBase<ordinal_type, value_type, node_type>(basis_, Cijk_, params_)
19 {
20 }
21 
22 template <typename ordinal_type, typename value_type>
23 void
27 {
28  if (a.size() == 1) {
29  if (c.size() != 1)
30  c.resize(1);
31  c[0] = std::exp(a[0]);
32  }
33  else
34  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
35  "Stokhos::AlgebraicOrthogPolyExpansion::exp()"
36  << ": Method not implemented!");
37 
38 }
39 
40 template <typename ordinal_type, typename value_type>
41 void
45 {
46  if (a.size() == 1) {
47  if (c.size() != 1)
48  c.resize(1);
49  c[0] = std::log(a[0]);
50  }
51  else
52  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
53  "Stokhos::AlgebraicOrthogPolyExpansion::log()"
54  << ": Method not implemented!");
55 }
56 
57 template <typename ordinal_type, typename value_type>
58 void
62 {
63  if (a.size() == 1) {
64  if (c.size() != 1)
65  c.resize(1);
66  c[0] = std::log10(a[0]);
67  }
68  else
69  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
70  "Stokhos::AlgebraicOrthogPolyExpansion::log10()"
71  << ": Method not implemented!");
72 }
73 
74 template <typename ordinal_type, typename value_type>
75 void
79 {
80  if (a.size() == 1) {
81  if (c.size() != 1)
82  c.resize(1);
83  c[0] = std::sqrt(a[0]);
84  }
85  else
86  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
87  "Stokhos::AlgebraicOrthogPolyExpansion::sqrt()"
88  << ": Method not implemented!");
89 }
90 
91 template <typename ordinal_type, typename value_type>
92 void
96 {
97  if (a.size() == 1) {
98  if (c.size() != 1)
99  c.resize(1);
100  c[0] = std::cbrt(a[0]);
101  }
102  else
103  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
104  "Stokhos::AlgebraicOrthogPolyExpansion::cbrt()"
105  << ": Method not implemented!");
106 }
107 
108 template <typename ordinal_type, typename value_type>
109 void
114 {
115  if (a.size() == 1 && b.size() == 1) {
116  if (c.size() != 1)
117  c.resize(1);
118  c[0] = std::pow(a[0], b[0]);
119  }
120  else
121  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
122  "Stokhos::AlgebraicOrthogPolyExpansion::pow()"
123  << ": Method not implemented!");
124 }
125 
126 template <typename ordinal_type, typename value_type>
127 void
130  const value_type& a,
132 {
133  if (b.size() == 1) {
134  if (c.size() != 1)
135  c.resize(1);
136  c[0] = std::pow(a, b[0]);
137  }
138  else
139  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
140  "Stokhos::AlgebraicOrthogPolyExpansion::pow()"
141  << ": Method not implemented!");
142 }
143 
144 template <typename ordinal_type, typename value_type>
145 void
149  const value_type& b)
150 {
151  if (a.size() == 1) {
152  if (c.size() != 1)
153  c.resize(1);
154  c[0] = std::pow(a[0], b);
155  }
156  else
157  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
158  "Stokhos::AlgebraicOrthogPolyExpansion::pow()"
159  << ": Method not implemented!");
160 }
161 
162 template <typename ordinal_type, typename value_type>
163 void
167 {
168  if (a.size() == 1) {
169  if (s.size() != 1)
170  s.resize(1);
171  s[0] = std::sin(a[0]);
172  }
173  else
174  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
175  "Stokhos::AlgebraicOrthogPolyExpansion::sin()"
176  << ": Method not implemented!");
177 }
178 
179 template <typename ordinal_type, typename value_type>
180 void
184 {
185  if (a.size() == 1) {
186  if (c.size() != 1)
187  c.resize(1);
188  c[0] = std::cos(a[0]);
189  }
190  else
191  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
192  "Stokhos::AlgebraicOrthogPolyExpansion::cos()"
193  << ": Method not implemented!");
194 }
195 
196 template <typename ordinal_type, typename value_type>
197 void
201 {
202  if (a.size() == 1) {
203  if (t.size() != 1)
204  t.resize(1);
205  t[0] = std::tan(a[0]);
206  }
207  else
208  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
209  "Stokhos::AlgebraicOrthogPolyExpansion::tan()"
210  << ": Method not implemented!");
211 }
212 
213 template <typename ordinal_type, typename value_type>
214 void
218 {
219  if (a.size() == 1) {
220  if (s.size() != 1)
221  s.resize(1);
222  s[0] = std::sinh(a[0]);
223  }
224  else
225  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
226  "Stokhos::AlgebraicOrthogPolyExpansion::sinh()"
227  << ": Method not implemented!");
228 }
229 
230 template <typename ordinal_type, typename value_type>
231 void
235 {
236  if (a.size() == 1) {
237  if (c.size() != 1)
238  c.resize(1);
239  c[0] = std::cosh(a[0]);
240  }
241  else
242  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
243  "Stokhos::AlgebraicOrthogPolyExpansion::cosh()"
244  << ": Method not implemented!");
245 }
246 
247 template <typename ordinal_type, typename value_type>
248 void
252 {
253  if (a.size() == 1) {
254  if (t.size() != 1)
255  t.resize(1);
256  t[0] = std::tanh(a[0]);
257  }
258  else
259  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
260  "Stokhos::AlgebraicOrthogPolyExpansion::tanh()"
261  << ": Method not implemented!");
262 }
263 
264 template <typename ordinal_type, typename value_type>
265 void
269 {
270  if (a.size() == 1) {
271  if (c.size() != 1)
272  c.resize(1);
273  c[0] = std::acos(a[0]);
274  }
275  else
276  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
277  "Stokhos::AlgebraicOrthogPolyExpansion::acos()"
278  << ": Method not implemented!");
279 }
280 
281 template <typename ordinal_type, typename value_type>
282 void
286 {
287  if (a.size() == 1) {
288  if (c.size() != 1)
289  c.resize(1);
290  c[0] = std::asin(a[0]);
291  }
292  else
293  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
294  "Stokhos::AlgebraicOrthogPolyExpansion::asin()"
295  << ": Method not implemented!");
296 }
297 
298 template <typename ordinal_type, typename value_type>
299 void
303 {
304  if (a.size() == 1) {
305  if (c.size() != 1)
306  c.resize(1);
307  c[0] = std::atan(a[0]);
308  }
309  else
310  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
311  "Stokhos::AlgebraicOrthogPolyExpansion::atan()"
312  << ": Method not implemented!");
313 }
314 
315 template <typename ordinal_type, typename value_type>
316 void
321 {
322  if (a.size() == 1 && b.size() == 1) {
323  if (c.size() != 1)
324  c.resize(1);
325  c[0] = std::atan2(a[0], b[0]);
326  }
327  else
328  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
329  "Stokhos::AlgebraicOrthogPolyExpansion::atan2()"
330  << ": Method not implemented!");
331 }
332 
333 template <typename ordinal_type, typename value_type>
334 void
337  const value_type& a,
339 {
340  if (b.size() == 1) {
341  if (c.size() != 1)
342  c.resize(1);
343  c[0] = std::atan2(a, b[0]);
344  }
345  else
346  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
347  "Stokhos::AlgebraicOrthogPolyExpansion::atan2()"
348  << ": Method not implemented!");
349 }
350 
351 template <typename ordinal_type, typename value_type>
352 void
356  const value_type& b)
357 {
358  if (a.size() == 1) {
359  if (c.size() != 1)
360  c.resize(1);
361  c[0] = std::atan2(a[0], b);
362  }
363  else
364  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
365  "Stokhos::AlgebraicOrthogPolyExpansion::atan2()"
366  << ": Method not implemented!");
367 }
368 
369 template <typename ordinal_type, typename value_type>
370 void
374 {
375  if (a.size() == 1) {
376  if (c.size() != 1)
377  c.resize(1);
378  c[0] = std::log(a[0]+std::sqrt(a[0]*a[0]-value_type(1.0)));
379  }
380  else
381  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
382  "Stokhos::AlgebraicOrthogPolyExpansion::acosh()"
383  << ": Method not implemented!");
384 }
385 
386 template <typename ordinal_type, typename value_type>
387 void
391 {
392  if (a.size() == 1) {
393  if (c.size() != 1)
394  c.resize(1);
395  c[0] = std::log(a[0]+std::sqrt(a[0]*a[0]+value_type(1.0)));
396  }
397  else
398  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
399  "Stokhos::AlgebraicOrthogPolyExpansion::asinh()"
400  << ": Method not implemented!");
401 }
402 
403 template <typename ordinal_type, typename value_type>
404 void
408 {
409  if (a.size() == 1) {
410  if (c.size() != 1)
411  c.resize(1);
412  c[0] = 0.5*std::log((value_type(1.0)+a[0])/(value_type(1.0)-a[0]));
413  }
414  else
415  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
416  "Stokhos::AlgebraicOrthogPolyExpansion::atanh()"
417  << ": Method not implemented!");
418 }
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)