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_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>
54 
56  typedef ExecutionSpace execution_space;
59 
62 
65 
68 
72 
75  if (this != &ep) {
76  eig_val = ep.eig_val;
77  eig_pairs = ep.eig_pairs;
78  }
79  return *this;
80  }
81 
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++)
89  }
90 
92  template <typename point_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>
127  public std::binary_function<ProductEigenPair<E,D>,
128  ProductEigenPair<E,D>,
129  bool> {
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
Container for multi-dimensional product of 1-D eigenfunctions/values.
eig_pair_type eig_pairs
Eigenpairs for each dimension.
Container for one-dimensional eigenfunction and eigenvalue.
void set(const Teuchos::Array< one_d_eigen_pair_type > &ep)
Set eigen pairs.
Teuchos::Array< one_d_eigen_pair_type > eig_pair_type
bool operator()(const ProductEigenPair< E, D > &a, const ProductEigenPair< E, D > &b)
KOKKOS_INLINE_FUNCTION value_type evalEigenfunction(const point_type &x) const
Evaluate eigenfunction at a given point.
OneDEigenPair< eigen_function_type > one_d_eigen_pair_type
void print(std::ostream &os) const
Print eigenpair.
ProductEigenPair & operator=(const ProductEigenPair &ep)
Assignment.
Predicate class for sorting product eigenfunctions based on eigenvalue.
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
size_type size() const
eigen_function_type::value_type value_type
ProductEigenPair(const ProductEigenPair &ep)
Copy constructor.
value_type eig_val
Product eigenvalue.