Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_KL_OneDExponentialEigenPair.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#ifndef STOKHOS_KL_ONE_D_EXPONENTIAL_EIGENPAIR_HPP
43#define STOKHOS_KL_ONE_D_EXPONENTIAL_EIGENPAIR_HPP
44
45#include <iostream>
46#include <cmath>
47
48#include "Kokkos_Core.hpp"
49
50namespace Stokhos {
51
53 namespace KL {
54
56 template <typename eigen_function_type>
58 typedef typename eigen_function_type::value_type value_type;
59 eigen_function_type eig_func;
61 }; // struct OneDEigenPair
62
64
72 template <typename Value>
74 public:
75
76 typedef Value value_type;
77
79 enum TYPE {
81 COS
82 };
83
85 KOKKOS_INLINE_FUNCTION
87 type(SIN), a(0), b(0), A(0), omega(0), dim_name(0) {}
88
90 KOKKOS_INLINE_FUNCTION
92 const value_type& b_,
93 const value_type& omega_,
94 const int dim_name_) :
95 type(type_), a((b_-a_)/2.0), b((b_+a_)/2.0), omega(omega_),
96 dim_name(dim_name_) {
97 if (type == SIN)
98 A = 1.0/std::sqrt(a - std::sin(2.*omega*a)/(2.*omega));
99 else
100 A = 1.0/std::sqrt(a + std::sin(2.*omega*a)/(2.*omega));
101 }
102
104 KOKKOS_INLINE_FUNCTION
106
108 template <typename point_type>
109 KOKKOS_INLINE_FUNCTION
110 point_type
111 evaluate(const point_type& x) const {
112 if (type == SIN)
113 return A*sin(omega*(x-b));
114 return A*cos(omega*(x-b));
115 }
116
118 void print(std::ostream& os) const {
119 os << A << " * ";
120 if (type == SIN)
121 os << "sin(";
122 else
123 os << "cos(";
124 os << omega << " * (x_" << dim_name << " - " << b << "))";
125 }
126
128 KOKKOS_INLINE_FUNCTION
129 TYPE getType() const { return type; }
130
132 KOKKOS_INLINE_FUNCTION
133 value_type getFrequency() const { return omega; }
134
136 KOKKOS_INLINE_FUNCTION
137 value_type getMultiplier() const { return A; }
138
140 KOKKOS_INLINE_FUNCTION
141 value_type getShift() const { return b; }
142
143 protected:
144
147
150
153
156
159
162 };
163
164 } // namespace KL
165
166} // namespace Stokhos
167
168#endif // STOKHOS_KL_ONE_D_EXPONENTIALEIGENPAIR_HPP
One-dimensional eigenfunction for exponential covariance function.
KOKKOS_INLINE_FUNCTION ExponentialOneDEigenFunction(TYPE type_, const value_type &a_, const value_type &b_, const value_type &omega_, const int dim_name_)
Constructor.
KOKKOS_INLINE_FUNCTION point_type evaluate(const point_type &x) const
Evaluate eigenfunction.
KOKKOS_INLINE_FUNCTION TYPE getType() const
Return type.
KOKKOS_INLINE_FUNCTION ~ExponentialOneDEigenFunction()
Destructor.
int dim_name
Dimesion name (e.g., x_1) for printing eigenfunction.
KOKKOS_INLINE_FUNCTION value_type getMultiplier() const
Return multiplier.
void print(std::ostream &os) const
Print eigenfunction.
KOKKOS_INLINE_FUNCTION value_type getFrequency() const
Return frequency.
KOKKOS_INLINE_FUNCTION value_type getShift() const
Get shift.
KOKKOS_INLINE_FUNCTION ExponentialOneDEigenFunction()
Default Constructor.
Top-level namespace for Stokhos classes and functions.
Container for one-dimensional eigenfunction and eigenvalue.
eigen_function_type::value_type value_type