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_OneDExponentialCovarianceFunction.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_COVARIANCE_FUNCTION_HPP
11 #define STOKHOS_KL_ONE_D_EXPONENTIAL_COVARIANCE_FUNCTION_HPP
12 
13 #include <string>
14 #include <cmath>
16 #include "Teuchos_ScalarTraits.hpp"
18 
19 namespace Stokhos {
20 
21  namespace KL {
22 
86  template <typename value_type>
88  public:
89 
92 
95  const value_type& a,
96  const value_type& b,
97  const value_type& L,
98  const int dim_name,
99  Teuchos::ParameterList& solverParams);
100 
103 
106  const value_type& xp) const {
107  return std::exp(-std::abs(x-xp)/L);
108  }
109 
112  return eig_pair;
113  }
114 
115  private:
116 
119 
122 
123  protected:
124 
126 
129 
132 
134  template <class Func>
135  value_type newton(const Func& func, const value_type& a,
136  const value_type& b, magnitude_type tol,
137  int max_num_its);
138 
140  template <class Func>
141  value_type bisection(const Func& func, const value_type& a,
142  const value_type& b, magnitude_type tol,
143  int max_num_its);
144 
149  struct EigFuncSin {
151  EigFuncSin(const value_type& alpha_) : alpha(alpha_) {}
152  value_type eval(const value_type& u) const {
153  return alpha*std::tan(u) + u; }
154  value_type deriv(const value_type& u) const {
155  return alpha/(std::cos(u)*std::cos(u)) + 1.0; }
156  };
157 
162  struct EigFuncCos {
164  EigFuncCos(const value_type& alpha_) : alpha(alpha_) {}
165  value_type eval(const value_type& u) const {
166  return alpha - u*std::tan(u); }
167  value_type deriv(const value_type& u) const {
168  return -std::tan(u) - u/(std::cos(u)*std::cos(u)); }
169  };
170 
171  }; // class OneDExponentialCovarianceFunction
172 
173  } // namespace KL
174 
175 } // namespace Stokhos
176 
177 // Include template definitions
179 
180 #endif // STOKHOS_KL_ONE_D_EXPONENTIAL_COVARIANCE_FUNCTION_HPP
KOKKOS_INLINE_FUNCTION PCE< Storage > tan(const PCE< Storage > &a)
value_type bisection(const Func &func, const value_type &a, const value_type &b, magnitude_type tol, int max_num_its)
A basic root finder based on bisection.
value_type newton(const Func &func, const value_type &a, const value_type &b, magnitude_type tol, int max_num_its)
A basic root finder based on Newton&#39;s method.
Container for one-dimensional eigenfunction and eigenvalue.
OneDExponentialCovarianceFunction & operator=(const OneDExponentialCovarianceFunction &)
Prohibit copying.
value_type evaluateCovariance(const value_type &x, const value_type &xp) const
Evaluate covariance.
OneDExponentialCovarianceFunction(int M, const value_type &a, const value_type &b, const value_type &L, const int dim_name, Teuchos::ParameterList &solverParams)
Constructor.
Nonlinear function whose roots define eigenvalues for cos() eigenfunction.
Nonlinear function whose roots define eigenvalues for sin() eigenfunction.
KOKKOS_INLINE_FUNCTION PCE< Storage > abs(const PCE< Storage > &a)
Class representing an exponential covariance function and its KL eigevalues/eigenfunctions.
KOKKOS_INLINE_FUNCTION PCE< Storage > exp(const PCE< Storage > &a)
Teuchos::ScalarTraits< value_type >::magnitudeType magnitude_type
const Teuchos::Array< eigen_pair_type > & getEigenPairs() const
Get eigenpairs.
One-dimensional eigenfunction for exponential covariance function.
KOKKOS_INLINE_FUNCTION PCE< Storage > cos(const PCE< Storage > &a)