Celeritas
0.5.0-86+4a8eea4
|
Wrap a numerical single-argument function with a counter and logger. More...
#include <DiagnosticRealFunc.hh>
Public Member Functions | |
DiagnosticRealFunc (F &&eval) | |
Construct by forwarding a function. | |
size_type | exchange_count () |
Get and reset the counter. | |
real_type | operator() (real_type v) |
Evaluate the underlying function and increment the counter. | |
Wrap a numerical single-argument function with a counter and logger.
This takes a function:
\[ f\colon\mathbb{R^1}\to\mathbb{R^1} \]
and adds a counter that increments every time the function is invoked. This is very useful for unit testing the convergence properties of numerical integrators, root finders, etc.
Example:
This wrapper also checks the input and output for NaN, and it outputs the function counter and evaluation to the logger (export CELER_LOG=debug
).