Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Stokhos_KL_ProductEigenPair.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_PRODUCT_EIGENPAIR_HPP
43
#define STOKHOS_KL_PRODUCT_EIGENPAIR_HPP
44
45
#include "Teuchos_Array.hpp"
46
47
namespace
Stokhos
{
48
49
namespace
KL
{
50
52
template
<
typename
eigen_function_type,
typename
ExecutionSpace>
53
struct
ProductEigenPair
{
54
55
typedef
typename
eigen_function_type::value_type
value_type
;
56
typedef
ExecutionSpace
execution_space
;
57
typedef
OneDEigenPair<eigen_function_type>
one_d_eigen_pair_type
;
58
typedef
Teuchos::Array<one_d_eigen_pair_type>
eig_pair_type
;
59
61
value_type
eig_val
;
62
64
eig_pair_type
eig_pairs
;
65
67
ProductEigenPair
() :
eig_val
(0.0),
eig_pairs
() {}
68
70
ProductEigenPair
(
const
ProductEigenPair
& ep) :
71
eig_val
(ep.
eig_val
),
eig_pairs
(ep.
eig_pairs
) {}
72
74
ProductEigenPair
&
operator=
(
const
ProductEigenPair
& ep) {
75
if
(
this
!= &ep) {
76
eig_val
= ep.
eig_val
;
77
eig_pairs
= ep.
eig_pairs
;
78
}
79
return
*
this
;
80
}
81
83
void
set
(
const
Teuchos::Array<one_d_eigen_pair_type>& ep) {
84
eig_val
= 1.0;
85
eig_pairs
= ep;
86
std::size_t sz =
eig_pairs
.size();
87
for
(std::size_t i=0; i<sz; i++)
88
eig_val
*=
eig_pairs
[i].
eig_val
;
89
}
90
92
template
<
typename
po
int
_type>
93
KOKKOS_INLINE_FUNCTION
94
value_type
evalEigenfunction
(
const
point_type& x)
const
{
95
value_type
result = 1.0;
96
std::size_t sz =
eig_pairs
.size();
97
for
(std::size_t i=0; i<sz; i++)
98
result *=
eig_pairs
[i].eig_func.evaluate(x[i]);
99
return
result;
100
}
101
103
void
print
(std::ostream& os)
const
{
104
os <<
eig_val
<<
", "
;
105
std::size_t sz =
eig_pairs
.size();
106
for
(std::size_t i=0; i<sz-1; i++) {
107
os <<
"("
;
108
eig_pairs
[i].eig_func.print(os);
109
os <<
") * "
;
110
}
111
os <<
"("
;
112
eig_pairs
[
eig_pairs
.size()-1].eig_func.print(os);
113
os <<
")"
;
114
}
115
};
116
117
template
<
typename
E,
typename
D>
118
std::ostream&
119
operator <<
(std::ostream& os,
const
ProductEigenPair<E,D>
&
f
) {
120
f
.print(os);
121
return
os;
122
}
123
125
template
<
typename
E,
typename
D>
126
struct
ProductEigenPairGreater
:
127
public
std::binary_function<ProductEigenPair<E,D>,
128
ProductEigenPair<E,D>,
129
bool> {
130
bool
operator()
(
const
ProductEigenPair<E,D>
& a,
131
const
ProductEigenPair<E,D>
& b) {
132
return
a.
eig_val
> b.
eig_val
;
133
}
134
};
// struct ProductEigenPairGreater
135
136
}
// namespace KL
137
138
}
// namespace Stokhos
139
140
#endif
// STOKHOS_KL_PRODUCT_EIGENPAIR_HPP
f
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
Definition
gram_schmidt_example3.cpp:98
Stokhos::KL
Namespace for analytic KL expansions.
Definition
Stokhos_KL_ExponentialRandomField.hpp:54
Stokhos::KL::operator<<
std::ostream & operator<<(std::ostream &os, const ProductEigenPair< E, D > &f)
Definition
Stokhos_KL_ProductEigenPair.hpp:119
Stokhos
Top-level namespace for Stokhos classes and functions.
Definition
Stokhos_AbstractPreconditionerFactory.hpp:48
Stokhos::KL::OneDEigenPair
Container for one-dimensional eigenfunction and eigenvalue.
Definition
Stokhos_KL_OneDExponentialEigenPair.hpp:57
Stokhos::KL::ProductEigenPairGreater
Predicate class for sorting product eigenfunctions based on eigenvalue.
Definition
Stokhos_KL_ProductEigenPair.hpp:129
Stokhos::KL::ProductEigenPairGreater::operator()
bool operator()(const ProductEigenPair< E, D > &a, const ProductEigenPair< E, D > &b)
Definition
Stokhos_KL_ProductEigenPair.hpp:130
Stokhos::KL::ProductEigenPair
Container for multi-dimensional product of 1-D eigenfunctions/values.
Definition
Stokhos_KL_ProductEigenPair.hpp:53
Stokhos::KL::ProductEigenPair::set
void set(const Teuchos::Array< one_d_eigen_pair_type > &ep)
Set eigen pairs.
Definition
Stokhos_KL_ProductEigenPair.hpp:83
Stokhos::KL::ProductEigenPair::operator=
ProductEigenPair & operator=(const ProductEigenPair &ep)
Assignment.
Definition
Stokhos_KL_ProductEigenPair.hpp:74
Stokhos::KL::ProductEigenPair::ProductEigenPair
ProductEigenPair(const ProductEigenPair &ep)
Copy constructor.
Definition
Stokhos_KL_ProductEigenPair.hpp:70
Stokhos::KL::ProductEigenPair< one_d_eigen_func_type, execution_space >::execution_space
execution_space execution_space
Definition
Stokhos_KL_ProductEigenPair.hpp:56
Stokhos::KL::ProductEigenPair< one_d_eigen_func_type, execution_space >::eig_val
value_type eig_val
Definition
Stokhos_KL_ProductEigenPair.hpp:61
Stokhos::KL::ProductEigenPair::ProductEigenPair
ProductEigenPair()
Default constructor.
Definition
Stokhos_KL_ProductEigenPair.hpp:67
Stokhos::KL::ProductEigenPair< one_d_eigen_func_type, execution_space >::eig_pairs
eig_pair_type eig_pairs
Definition
Stokhos_KL_ProductEigenPair.hpp:64
Stokhos::KL::ProductEigenPair::evalEigenfunction
KOKKOS_INLINE_FUNCTION value_type evalEigenfunction(const point_type &x) const
Evaluate eigenfunction at a given point.
Definition
Stokhos_KL_ProductEigenPair.hpp:94
Stokhos::KL::ProductEigenPair< one_d_eigen_func_type, execution_space >::value_type
one_d_eigen_func_type::value_type value_type
Definition
Stokhos_KL_ProductEigenPair.hpp:55
Stokhos::KL::ProductEigenPair< one_d_eigen_func_type, execution_space >::one_d_eigen_pair_type
OneDEigenPair< one_d_eigen_func_type > one_d_eigen_pair_type
Definition
Stokhos_KL_ProductEigenPair.hpp:57
Stokhos::KL::ProductEigenPair::print
void print(std::ostream &os) const
Print eigenpair.
Definition
Stokhos_KL_ProductEigenPair.hpp:103
Stokhos::KL::ProductEigenPair< one_d_eigen_func_type, execution_space >::eig_pair_type
Teuchos::Array< one_d_eigen_pair_type > eig_pair_type
Definition
Stokhos_KL_ProductEigenPair.hpp:58
Generated by
1.17.0