Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_KL_OneDExponentialEigenPair.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 #ifndef STOKHOS_KL_ONE_D_EXPONENTIAL_EIGENPAIR_HPP
11 #define STOKHOS_KL_ONE_D_EXPONENTIAL_EIGENPAIR_HPP
12 
13 #include <iostream>
14 #include <cmath>
15 
16 #include "Kokkos_Core.hpp"
17 
18 namespace Stokhos {
19 
21  namespace KL {
22 
24  template <typename eigen_function_type>
25  struct OneDEigenPair {
27  eigen_function_type eig_func;
29  }; // struct OneDEigenPair
30 
32 
40  template <typename Value>
42  public:
43 
44  typedef Value value_type;
45 
47  enum TYPE {
48  SIN,
49  COS
50  };
51 
53  KOKKOS_INLINE_FUNCTION
55  type(SIN), a(0), b(0), A(0), omega(0), dim_name(0) {}
56 
58  KOKKOS_INLINE_FUNCTION
60  const value_type& b_,
61  const value_type& omega_,
62  const int dim_name_) :
63  type(type_), a((b_-a_)/2.0), b((b_+a_)/2.0), omega(omega_),
64  dim_name(dim_name_) {
65  if (type == SIN)
66  A = 1.0/std::sqrt(a - std::sin(2.*omega*a)/(2.*omega));
67  else
68  A = 1.0/std::sqrt(a + std::sin(2.*omega*a)/(2.*omega));
69  }
70 
72  KOKKOS_INLINE_FUNCTION
74 
76  template <typename point_type>
77  KOKKOS_INLINE_FUNCTION
78  point_type
79  evaluate(const point_type& x) const {
80  if (type == SIN)
81  return A*sin(omega*(x-b));
82  return A*cos(omega*(x-b));
83  }
84 
86  void print(std::ostream& os) const {
87  os << A << " * ";
88  if (type == SIN)
89  os << "sin(";
90  else
91  os << "cos(";
92  os << omega << " * (x_" << dim_name << " - " << b << "))";
93  }
94 
96  KOKKOS_INLINE_FUNCTION
97  TYPE getType() const { return type; }
98 
100  KOKKOS_INLINE_FUNCTION
101  value_type getFrequency() const { return omega; }
102 
104  KOKKOS_INLINE_FUNCTION
105  value_type getMultiplier() const { return A; }
106 
108  KOKKOS_INLINE_FUNCTION
109  value_type getShift() const { return b; }
110 
111  protected:
112 
115 
118 
121 
124 
127 
129  int dim_name;
130  };
131 
132  } // namespace KL
133 
134 } // namespace Stokhos
135 
136 #endif // STOKHOS_KL_ONE_D_EXPONENTIALEIGENPAIR_HPP
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
KOKKOS_INLINE_FUNCTION value_type getFrequency() const
Return frequency.
KOKKOS_INLINE_FUNCTION ExponentialOneDEigenFunction(TYPE type_, const value_type &a_, const value_type &b_, const value_type &omega_, const int dim_name_)
Constructor.
Container for one-dimensional eigenfunction and eigenvalue.
KOKKOS_INLINE_FUNCTION ~ExponentialOneDEigenFunction()
Destructor.
void print(std::ostream &os) const
Print eigenfunction.
KOKKOS_INLINE_FUNCTION value_type getMultiplier() const
Return multiplier.
eigen_function_type::value_type value_type
KOKKOS_INLINE_FUNCTION point_type evaluate(const point_type &x) const
Evaluate eigenfunction.
TYPE
Enum identifying the type of eigenfunction.
KOKKOS_INLINE_FUNCTION value_type getShift() const
Get shift.
KOKKOS_INLINE_FUNCTION ExponentialOneDEigenFunction()
Default Constructor.
KOKKOS_INLINE_FUNCTION PCE< Storage > sin(const PCE< Storage > &a)
One-dimensional eigenfunction for exponential covariance function.
int dim_name
Dimesion name (e.g., x_1) for printing eigenfunction.
KOKKOS_INLINE_FUNCTION TYPE getType() const
Return type.
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)