Skip to content

Commit 40bd51f

Browse files
committed
quadrature: Add expected_error routine.
1 parent b27bfb6 commit 40bd51f

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

include/pfasst/quadrature/interface.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace pfasst
6363
/**
6464
* Compute quadrature matrix \\( Q \\) between two sets of nodes.
6565
*
66-
* Computing the quadrature matrix \\( Q \\) for polynomial-based integration from one set of
66+
* Computing the quadrature matrix \\( Q \\) for polynomial-based integration from one set of
6767
* quadrature nodes (@p from) to another set of quadrature nodes (@p to).
6868
*
6969
* @tparam scalar precision of quadrature (i.e. `double`)
@@ -145,7 +145,7 @@ namespace pfasst
145145
* The \\( S \\) matrix provides a node-to-node quadrature where the \\( i \\)-th row of
146146
* \\( S \\) represents a quadrature from the \\( i-1 \\)-th node to the \\( i \\)-th node.
147147
*
148-
* The procedure is simply subtracting the \\( i-1 \\)-th row of \\( Q \\) from the
148+
* The procedure is simply subtracting the \\( i-1 \\)-th row of \\( Q \\) from the
149149
* \\( i \\)-th row of \\( Q \\).
150150
*
151151
* @tparam scalar precision of quadrature (i.e. `double`)
@@ -264,6 +264,7 @@ namespace pfasst
264264
virtual const vector<precision>& get_q_vec() const;
265265
virtual const vector<precision>& get_nodes() const;
266266
virtual size_t get_num_nodes() const;
267+
267268
/**
268269
* @throws pfasst::NotImplementedYet if not overwritten by implementation;
269270
* required for quadrature of any kind
@@ -276,6 +277,11 @@ namespace pfasst
276277
virtual bool right_is_node() const;
277278
//! @}
278279

280+
/**
281+
* Compute a rough estimate of the numerical error... XXX
282+
*/
283+
precision expected_error() const;
284+
279285
protected:
280286
//! @{
281287
/**

src/pfasst/quadrature/interface_impl.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ namespace pfasst
7474
throw NotImplementedYet("Quadrature");
7575
}
7676

77+
template<typename precision>
78+
precision IQuadrature<precision>::expected_error() const
79+
{
80+
using vec = Eigen::Array<precision, 1, Eigen::Dynamic>;
81+
const vec row_sums = this->get_q_mat().rowwise().sum();
82+
Eigen::Map<const vec> nodes(this->get_nodes().data(), this->get_nodes().size());
83+
return (row_sums - nodes).maxCoeff();
84+
}
85+
7786
/**
7887
* @internals
7988
* Computing weights means computing \\( Q \\) and \\( S \\) matrices as well as the \\( q \\)

0 commit comments

Comments
 (0)