Chebyshev
Unit testing for scientific software
|
Precision testing context, handling precision test cases. More...
#include <prec.h>
Public Member Functions | |
void | setup (const std::string &moduleName, int argc=0, const char **argv=nullptr) |
Setup the precision testing module. | |
void | terminate (bool exit=false) |
Terminate the precision testing module. | |
prec_context (const std::string &moduleName, int argc, const char **argv) | |
Construct a precision testing context. | |
~prec_context () | |
Destructor for the context, automatically terminates the module. | |
prec_context (const prec_context &other) | |
Custom copy constructor to avoid copying std::mutex. | |
prec_context & | operator= (const prec_context &other) |
Custom assignment operator to avoid copying std::mutex. | |
template<typename R , typename ... Args, typename Function1 = std::function<R(Args...)>, typename Function2 = Function1> | |
void | estimate (const std::string &name, Function1 funcApprox, Function2 funcExpected, estimate_options< R, Args... > opt) |
Estimate error integrals over a function with respect to an exact function, with the given options. | |
template<typename R , typename ... Args, typename Function1 = std::function<R(Args...)>, typename Function2 = Function1> | |
void | estimate (const std::string &name, Function1 funcApprox, Function2 funcExpected, std::vector< interval > domain, long double tolerance, unsigned int iterations, FailFunction fail, Estimator< R, Args... > estimator, bool quiet=false) |
Estimate error integrals over a function with respect to an exact function. | |
void | estimate (const std::string &name, EndoFunction< double > funcApprox, EndoFunction< double > funcExpected, interval domain, long double tolerance=get_nan(), unsigned int iterations=0, FailFunction fail=fail::fail_on_max_err(), Estimator< double, double > estimator=estimator::quadrature1D< double >(), bool quiet=false) |
Estimate error integrals over a real function of real variable, with respect to an exact function. | |
template<typename Type , typename Identity = EndoFunction<Type>> | |
void | identity (const std::string &name, Identity id, const estimate_options< Type, Type > &opt) |
Precision testing of an endofunction which is equivalent to the identity. | |
template<typename Type , typename Involution = EndoFunction<Type>> | |
void | involution (const std::string &name, Involution invol, const estimate_options< Type, Type > &opt) |
Precision testing of an endofunction which is an involution. | |
template<typename Type , typename Involution = EndoFunction<Type>> | |
void | idempotence (const std::string &name, Involution idem, const estimate_options< Type, Type > &opt) |
Precision testing of an endofunction which is idempotent. | |
template<typename InputType , typename OutputType = InputType, typename Homogeneous = std::function<OutputType(InputType)>> | |
void | homogeneous (const std::string &name, Homogeneous hom, const estimate_options< InputType, OutputType > &opt, OutputType zero_element=OutputType(0.0)) |
Precision testing of an function which is homogeneous over the domain. | |
template<typename Type = double> | |
void | equals (const std::string &name, const Type &evaluated, const Type &expected, equation_options< Type > opt=equation_options< Type >()) |
Test an equivalence up to a tolerance, with the given options (e.g. | |
template<typename Type = double> | |
void | equals (const std::string &name, const Type &evaluated, const Type &expected, long double tolerance, DistanceFunction< Type > distance, bool quiet=false) |
Test an equivalence up to a tolerance, with the given options (e.g. | |
void | equals (const std::string &name, long double evaluated, long double expected, long double tolerance=get_nan(), bool quiet=false) |
Test an equivalence up to a tolerance, with the given options (e.g. | |
template<typename Type > | |
void | equals (const std::string &name, std::vector< std::array< Type, 2 > > values, long double tolerance=get_nan(), bool quiet=false) |
Evaluate multiple pairs of values for equivalence up to the given tolerance (e.g. | |
void | wait_results () |
Wait for all concurrent test cases to finish execution. | |
std::vector< estimate_result > | get_estimate (const std::string &name) |
Get the results of error estimation by label. | |
estimate_result | get_estimate (const std::string &name, unsigned int i) |
Get a single result of error estimation by label and index. | |
std::vector< equation_result > | get_equation (const std::string &name) |
Get the results of equation testing by label. | |
equation_result | get_equation (const std::string &name, unsigned int i) |
Get a single result of equation testing by label and index. | |
Public Attributes | |
prec_settings | settings |
Settings for the precision testing context. | |
std::shared_ptr< output::output_context > | output |
Output module settings for the context, dynamically allocated and possibly shared between multiple contexts. | |
std::shared_ptr< random::random_context > | random |
Random module settings for the context, dynamically allocated and possibly shared between multiple contexts. | |
Precision testing context, handling precision test cases.
|
inline |
Construct a precision testing context.
moduleName | Name of the module under test |
argc | Number of command line arguments |
argv | List of command line arguments as C strings |
|
inline |
Test an equivalence up to a tolerance, with the given options (e.g.
for residual testing).
name | The name of the test case |
evaluate | The evaluated value |
expected | The expected value |
opt | The options for the evaluation |
|
inline |
Test an equivalence up to a tolerance, with the given options (e.g.
for residual testing).
name | The name of the test case |
evaluate | The evaluated value |
expected | The expected value |
distance | The distance function to use |
tolerance | The tolerance for the evaluation |
quiet | Whether to output the result |
|
inline |
Test an equivalence up to a tolerance, with the given options (e.g.
for residual testing).
name | The name of the test case |
evaluate | The evaluated value |
expected | The expected value |
tolerance | The tolerance for the evaluation |
quiet | Whether to output the result |
|
inline |
Evaluate multiple pairs of values for equivalence up to the given tolerance (e.g.
for residual testing).
name | The name of the function or test case |
values | A list of values to equate |
tolerance | The tolerance for the evaluation |
quiet | Whether to output the result |
|
inline |
Estimate error integrals over a real function of real variable, with respect to an exact function.
name | The name of the test case. |
funcApprox | The approximation to test. |
funcExpected | The expected result. |
intervals | The (potentially multidimensional) domain of estimation. |
iterations | The number of function evaluations. |
fail | The fail function to determine whether the test failed (defaults to fail_on_max_err). |
estimator | The precision estimator to use (defaults to the trapezoid<double> estimator). |
quiet | Whether to output the result. |
|
inline |
Estimate error integrals over a function with respect to an exact function, with the given options.
name | The name of the test case |
funcApprox | The approximation to test |
funcExpected | The expected result |
opt | The options for the estimation |
|
inline |
Estimate error integrals over a function with respect to an exact function.
name | The name of the test case. |
funcApprox | The approximation to test. |
funcExpected | The expected result. |
intervals | The (potentially multidimensional) domain of estimation. |
iterations | The number of function evaluations. |
fail | The fail function to determine whether the test failed. |
estimator | The precision estimator to use. |
quiet | Whether to output the result. |
|
inline |
Get the results of error estimation by label.
|
inline |
Get a single result of error estimation by label and index.
|
inline |
Precision testing of an function which is homogeneous over the domain.
The function is applied to input values and it is checked against zero. The zero value is constructed as OutputType(0.0), but may be specified as an additional argument.
name | The name of the test case. |
hom | The homogeneous function to test. |
opt | The options for estimation. |
zero_element | The zero element of type OutputType (defaults to OutputType(0.0)). |
|
inline |
Precision testing of an endofunction which is idempotent.
The function is applied two times to input values and it is checked against itself.
name | The name of the test case. |
idem | The idempotent function to test. |
opt | The options for estimation. |
|
inline |
Precision testing of an endofunction which is equivalent to the identity.
name | The name of the test case. |
id | The identity function to test. |
opt | The options for estimation. |
|
inline |
Precision testing of an endofunction which is an involution.
The function is applied two times to input values and it is checked against the identity.
name | The name of the test case. |
involution | The involution to test. |
opt | The options for estimation. |
|
inline |
Setup the precision testing module.
moduleName | Name of the module under test |
argc | Number of command line arguments |
argv | List of command line arguments as C strings |
Terminate the precision testing module.
exit | Whether to exit after finishing execution. |