5 #ifndef _PFASST__QUADRATURE__INTERFACE_HPP_
6 #define _PFASST__QUADRATURE__INTERFACE_HPP_
12 #include <Eigen/Dense>
13 template<
typename scalar>
14 using Matrix = Eigen::Matrix<scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
16 template<
typename scalar>
42 template<
typename scalar>
45 const size_t num_nodes = nodes.size();
49 for (
size_t m = 0; m < num_nodes; ++m) {
50 if (m == node) {
continue; }
54 for (
size_t j = 0; j < num_nodes; ++j) { p1[j + 1] = p[j]; }
55 for (
size_t j = 0; j < num_nodes + 1; ++j) { p1[j] -= p[j] * nodes[m]; }
56 for (
size_t j = 0; j < num_nodes + 1; ++j) { p[j] = p1[j]; }
79 template<
typename scalar>
82 const size_t to_size = to.size();
83 const size_t from_size = from.size();
84 assert(to_size >= 1 && from_size >= 1);
88 for (
size_t m = 0; m < from_size; ++m) {
93 for (
size_t j = 0; j < to_size; ++j) {
94 q_mat(j, m) = (P.evaluate(to[j]) - P.evaluate(0.0)) / den;
112 template<
typename scalar>
115 return compute_q_matrix<scalar>(nodes, nodes);
130 template<
typename scalar>
134 q_mat.col(0) = s_mat.col(0);
135 for (
Index<scalar> q_mat_col = 1; q_mat_col < q_mat.cols(); ++q_mat_col) {
136 q_mat.col(q_mat_col) = q_mat.col(q_mat_col - 1) + s_mat.col(q_mat_col);
157 template<
typename scalar>
161 s_mat.row(0) = q_mat.row(0);
163 s_mat.row(row) = q_mat.row(row) - q_mat.row(row - 1);
180 template<
typename scalar>
199 template<
typename scalar>
202 const size_t num_nodes = nodes.size();
203 assert(num_nodes >= 1);
205 vector<scalar> q_vec = vector<scalar>(num_nodes, scalar(0.0));
207 for (
size_t m = 0; m < num_nodes; ++m) {
212 q_vec[m] = (P.evaluate(scalar(1.0)) - P.evaluate(scalar(0.0))) / den;
231 template<
typename precision = pfasst::time_precision>
236 static const bool LEFT_IS_NODE =
false;
237 static const bool RIGHT_IS_NODE =
false;
264 virtual const vector<precision>& get_q_vec()
const;
265 virtual const vector<precision>& get_nodes()
const;
266 virtual size_t get_num_nodes()
const;
272 virtual bool left_is_node()
const;
277 virtual bool right_is_node()
const;
283 precision expected_error()
const;
292 virtual void compute_weights();
300 #endif // _PFASST__QUADRATURE__INTERFACE_HPP_
Representation of a polynomial including differentiation, integration and root finding.
vector< precision > q_vec
typename Matrix< scalar >::Index Index
Interface for quadrature handlers.
Quadrature handler for Clenshaw-Curtis quadrature.
QuadratureType
Quadrature type descriptors.
Polynomial< CoeffT > integrate() const
Integrates this polynomial.
vector< precision > nodes
Quadrature handler for Gauss-Lobatto quadrature.
Matrix< precision > b_mat
Quadrature handler for Gauss-Radau quadrature.
vector< precision > compute_nodes(size_t nnodes, QuadratureType qtype)
Compute quadrature nodes for given quadrature type descriptor.
Quadrature handler for Gauss-Legendre quadrature.
Matrix< precision > q_mat
interfaces for SDC/MLSDC/PFASST algorithms.
static vector< scalar > compute_q_vec(const vector< scalar > &nodes)
Compute vector \( q \) for integration from \( 0 \) to \( 1 \) for given set of nodes.
Matrix< precision > s_mat
static Matrix< scalar > compute_s_matrix(const vector< scalar > &from, const vector< scalar > &to)
Compute node-to-node quadrature matrix \( S \) from two given sets of nodes.
Eigen::Matrix< scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
static Matrix< scalar > compute_q_matrix(const Matrix< scalar > &s_mat)
Compute quadrature matrix \( Q \) from a given node-to-node quadrature matrix \( S \)...
static Polynomial< scalar > build_polynomial(const size_t node, const vector< scalar > &nodes)
xtype evaluate(const xtype x) const
Evaluate polynomial for given value.