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 // 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_PRODUCT_EIGENPAIR_HPP
11 #define STOKHOS_KL_PRODUCT_EIGENPAIR_HPP
12 
13 #include "Teuchos_Array.hpp"
14 
15 namespace Stokhos {
16 
17  namespace KL {
18 
20  template <typename eigen_function_type, typename ExecutionSpace>
22 
24  typedef ExecutionSpace execution_space;
27 
30 
33 
36 
40 
43  if (this != &ep) {
44  eig_val = ep.eig_val;
45  eig_pairs = ep.eig_pairs;
46  }
47  return *this;
48  }
49 
52  eig_val = 1.0;
53  eig_pairs = ep;
54  std::size_t sz = eig_pairs.size();
55  for (std::size_t i=0; i<sz; i++)
57  }
58 
60  template <typename point_type>
61  KOKKOS_INLINE_FUNCTION
62  value_type evalEigenfunction(const point_type& x) const {
63  value_type result = 1.0;
64  std::size_t sz = eig_pairs.size();
65  for (std::size_t i=0; i<sz; i++)
66  result *= eig_pairs[i].eig_func.evaluate(x[i]);
67  return result;
68  }
69 
71  void print(std::ostream& os) const {
72  os << eig_val << ", ";
73  std::size_t sz = eig_pairs.size();
74  for (std::size_t i=0; i<sz-1; i++) {
75  os << "(";
76  eig_pairs[i].eig_func.print(os);
77  os << ") * ";
78  }
79  os << "(";
80  eig_pairs[eig_pairs.size()-1].eig_func.print(os);
81  os << ")";
82  }
83  };
84 
85  template <typename E, typename D>
86  std::ostream&
87  operator << (std::ostream& os, const ProductEigenPair<E,D>& f) {
88  f.print(os);
89  return os;
90  }
91 
93  template <typename E, typename D>
95  {
97  const ProductEigenPair<E,D>& b) {
98  return a.eig_val > b.eig_val;
99  }
100  }; // struct ProductEigenPairGreater
101 
102  } // namespace KL
103 
104 } // namespace Stokhos
105 
106 #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.