PFASST++
clenshaw_curtis_impl.hpp
Go to the documentation of this file.
2 
3 #include <stdexcept>
4 using namespace std;
5 
6 #include <boost/math/constants/constants.hpp>
7 using namespace boost::math::constants;
8 
10 
11 
12 namespace pfasst
13 {
14  namespace quadrature
15  {
16  template<typename precision>
18  : IQuadrature<precision>(num_nodes)
19  {
20  if (this->num_nodes < 2) {
21  throw invalid_argument("Clenshaw-Curtis quadrature requires at least two quadrature nodes.");
22  }
23  this->compute_nodes();
24  this->compute_weights();
25  }
26 
27  template<typename precision>
29  {
30  return LEFT_IS_NODE;
31  }
32 
33  template<typename precision>
35  {
36  return RIGHT_IS_NODE;
37  }
38 
39  template<typename precision>
41  {
42  this->nodes = vector<precision>(this->num_nodes, precision(0.0));
43  auto roots = Polynomial<precision>::legendre(this->num_nodes).roots();
44 
45  for (size_t j = 0; j < this->num_nodes; j++) {
46  this->nodes[j] = 0.5 * (1.0 - cos(j * pi<precision>() / (this->num_nodes - 1)));
47  }
48  }
49  } // ::pfasst::quadrature
50 } // ::pfasst
virtual bool right_is_node() const override
Interface for quadrature handlers.
Definition: interface.hpp:232
Quadrature handler for Clenshaw-Curtis quadrature.
STL namespace.
static Polynomial< CoeffT > legendre(const size_t order)
Computes the Legendre polynomial of given order.
virtual bool left_is_node() const override