10 #ifndef SACADO_PCE_ORTHOGPOLY_HPP
11 #define SACADO_PCE_ORTHOGPOLY_HPP
15 #ifdef HAVE_STOKHOS_SACADO
19 #include "Sacado_Traits.hpp"
20 #include "Sacado_Handle.hpp"
21 #include "Sacado_mpl_apply.hpp"
41 template <
typename T,
typename Storage >
66 typedef typename approx_type::pointer pointer;
67 typedef typename approx_type::const_pointer const_pointer;
68 typedef typename approx_type::reference reference;
69 typedef typename approx_type::const_reference const_reference;
74 typedef typename Sacado::mpl::apply<Storage,ordinal_type,S>::type
storage_type;
75 typedef OrthogPoly<S,storage_type> type;
104 OrthogPoly(
const OrthogPoly& x);
110 void init(
const T& v) { th->init(v); }
113 void init(
const T* v) { th->init(v); }
116 template <
typename S>
117 void init(
const OrthogPoly<T,S>& v) { th->init(v.getOrthogPolyApprox()); }
120 void load(T* v) { th->load(v); }
123 template <
typename S>
124 void load(OrthogPoly<T,S>& v) { th->load(v.getOrthogPolyApprox()); }
149 void copyForWrite() { th.makeOwnCopy(); }
162 value_type standard_deviation()
const {
return th->standard_deviation(); }
165 value_type two_norm()
const {
return th->two_norm(); }
168 value_type two_norm_squared()
const {
return th->two_norm_squared(); }
171 value_type inner_product(
const OrthogPoly& b)
const {
172 return th->inner_product(b.getOrthogPolyApprox()); }
175 std::ostream& print(std::ostream& os)
const {
return th->print(os); }
178 bool isEqualTo(
const OrthogPoly& x)
const;
189 OrthogPoly<T,Storage>& operator=(
const OrthogPoly<T,Storage>& x);
212 const_reference
val()
const {
return (*th)[0]; }
215 reference
val() {
return (*th)[0]; }
228 bool hasFastAccess(
ordinal_type sz)
const {
return th->size()>=sz;}
231 const_pointer coeff()
const {
return th->coeff();}
234 pointer coeff() {
return th->coeff();}
248 return th->term(dimension, order); }
252 return th->term(dimension, order); }
256 return th->order(term); }
272 OrthogPoly<T,Storage>& operator += (
const value_type& x);
275 OrthogPoly<T,Storage>& operator -= (
const value_type& x);
278 OrthogPoly<T,Storage>& operator *= (
const value_type& x);
281 OrthogPoly<T,Storage>& operator /= (
const value_type& x);
284 OrthogPoly<T,Storage>& operator += (
const OrthogPoly<T,Storage>& x);
287 OrthogPoly<T,Storage>& operator -= (
const OrthogPoly<T,Storage>& x);
290 OrthogPoly<T,Storage>& operator *= (
const OrthogPoly<T,Storage>& x);
293 OrthogPoly<T,Storage>& operator /= (
const OrthogPoly<T,Storage>& x);
298 const approx_type& getOrthogPolyApprox()
const {
return *th; }
301 approx_type& getOrthogPolyApprox() {
return *th; }
311 Sacado::Handle< Stokhos::OrthogPolyApprox<int,value_type,Storage> > th;
316 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
317 operator+(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
319 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
321 const OrthogPoly<T,Storage>& b);
323 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
324 operator+(
const OrthogPoly<T,Storage>& a,
327 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
328 operator-(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
330 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
332 const OrthogPoly<T,Storage>& b);
334 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
335 operator-(
const OrthogPoly<T,Storage>& a,
338 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
339 operator*(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
341 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
343 const OrthogPoly<T,Storage>& b);
345 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
346 operator*(
const OrthogPoly<T,Storage>& a,
349 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
350 operator/(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
352 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
354 const OrthogPoly<T,Storage>& b);
356 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
357 operator/(
const OrthogPoly<T,Storage>& a,
360 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
361 exp(
const OrthogPoly<T,Storage>& a);
363 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
364 log(
const OrthogPoly<T,Storage>& a);
366 template <
typename T,
typename Storage>
void
367 log(OrthogPoly<T,Storage>& c,
const OrthogPoly<T,Storage>& a);
369 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
370 log10(
const OrthogPoly<T,Storage>& a);
372 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
373 sqrt(
const OrthogPoly<T,Storage>& a);
375 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
376 cbrt(
const OrthogPoly<T,Storage>& a);
378 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
379 pow(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
381 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
383 const OrthogPoly<T,Storage>& b);
385 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
386 pow(
const OrthogPoly<T,Storage>& a,
389 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
390 cos(
const OrthogPoly<T,Storage>& a);
392 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
393 sin(
const OrthogPoly<T,Storage>& a);
395 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
396 tan(
const OrthogPoly<T,Storage>& a);
398 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
399 cosh(
const OrthogPoly<T,Storage>& a);
401 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
402 sinh(
const OrthogPoly<T,Storage>& a);
404 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
405 tanh(
const OrthogPoly<T,Storage>& a);
407 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
408 acos(
const OrthogPoly<T,Storage>& a);
410 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
411 asin(
const OrthogPoly<T,Storage>& a);
413 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
414 atan(
const OrthogPoly<T,Storage>& a);
416 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
417 atan2(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
419 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
421 const OrthogPoly<T,Storage>& b);
423 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
424 atan2(
const OrthogPoly<T,Storage>& a,
427 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
428 acosh(
const OrthogPoly<T,Storage>& a);
430 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
431 asinh(
const OrthogPoly<T,Storage>& a);
433 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
434 atanh(
const OrthogPoly<T,Storage>& a);
436 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
437 abs(
const OrthogPoly<T,Storage>& a);
439 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
440 fabs(
const OrthogPoly<T,Storage>& a);
442 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
443 max(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
445 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
447 const OrthogPoly<T,Storage>& b);
449 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
450 max(
const OrthogPoly<T,Storage>& a,
453 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
454 min(
const OrthogPoly<T,Storage>& a,
const OrthogPoly<T,Storage>& b);
456 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
458 const OrthogPoly<T,Storage>& b);
460 template <
typename T,
typename Storage> OrthogPoly<T,Storage>
461 min(
const OrthogPoly<T,Storage>& a,
464 template <
typename T,
typename Storage>
bool
466 const OrthogPoly<T,Storage>& b);
468 template <
typename T,
typename Storage>
bool
470 const OrthogPoly<T,Storage>& b);
472 template <
typename T,
typename Storage>
bool
476 template <
typename T,
typename Storage>
bool
478 const OrthogPoly<T,Storage>& b);
480 template <
typename T,
typename Storage>
bool
482 const OrthogPoly<T,Storage>& b);
484 template <
typename T,
typename Storage>
bool
488 template <
typename T,
typename Storage>
bool
489 operator<=(const OrthogPoly<T,Storage>& a,
490 const OrthogPoly<T,Storage>& b);
492 template <
typename T,
typename Storage>
bool
494 const OrthogPoly<T,Storage>& b);
496 template <
typename T,
typename Storage>
bool
497 operator<=(const OrthogPoly<T,Storage>& a,
500 template <
typename T,
typename Storage>
bool
502 const OrthogPoly<T,Storage>& b);
504 template <
typename T,
typename Storage>
bool
506 const OrthogPoly<T,Storage>& b);
508 template <
typename T,
typename Storage>
bool
512 template <
typename T,
typename Storage>
bool
513 operator<(const OrthogPoly<T,Storage>& a,
514 const OrthogPoly<T,Storage>& b);
516 template <
typename T,
typename Storage>
bool
518 const OrthogPoly<T,Storage>& b);
520 template <
typename T,
typename Storage>
bool
521 operator<(const OrthogPoly<T,Storage>& a,
524 template <
typename T,
typename Storage>
bool
525 operator>(
const OrthogPoly<T,Storage>& a,
526 const OrthogPoly<T,Storage>& b);
528 template <
typename T,
typename Storage>
bool
530 const OrthogPoly<T,Storage>& b);
532 template <
typename T,
typename Storage>
bool
533 operator>(
const OrthogPoly<T,Storage>& a,
536 template <
typename T,
typename Storage> std::ostream&
537 operator << (std::ostream& os, const OrthogPoly<T,Storage>& a);
539 template <
typename T,
typename Storage> std::istream&
540 operator >> (std::istream& os, OrthogPoly<T,Storage>& a);
549 #endif // HAVE_STOKHOS_SACADO
551 #endif // SACADO_PCE_ORTHOGPOLY_HPP
OrthogPoly< T, Storage > exp(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > log(const OrthogPoly< T, Storage > &a)
Stokhos::StandardStorage< int, double > storage_type
OrthogPoly< T, Storage > sin(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > sqrt(const OrthogPoly< T, Storage > &a)
bool operator>=(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > operator-(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > pow(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > atan(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > cbrt(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > acos(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > atanh(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > cosh(const OrthogPoly< T, Storage > &a)
std::istream & operator>>(std::istream &is, OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > sinh(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > tan(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > asin(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > operator+(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > operator/(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > max(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
atan2(expr1.val(), expr2.val())
Stokhos::LegendreBasis< int, double > basis_type
Abstract base class for orthogonal polynomial-based expansions.
bool operator!=(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
Abstract base class for multivariate orthogonal polynomials.
OrthogPoly< T, Storage > cos(const OrthogPoly< T, Storage > &a)
bool operator==(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > acosh(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > min(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j)-expr2.val(j)
OrthogPoly< T, Storage > log10(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > abs(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > fabs(const OrthogPoly< T, Storage > &a)
Class to store coefficients of a projection onto an orthogonal polynomial basis.
OrthogPoly< T, Storage > asinh(const OrthogPoly< T, Storage > &a)
OrthogPoly< T, Storage > tanh(const OrthogPoly< T, Storage > &a)
bool operator>(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)
OrthogPoly< T, Storage > operator*(const OrthogPoly< T, Storage > &a, const OrthogPoly< T, Storage > &b)