JayBeams  0.1
Another project to have fun coding.
Namespaces | Macros | Functions
check_close_enough.hpp File Reference
#include <boost/multi_array.hpp>
#include <boost/test/unit_test.hpp>
#include <cmath>
#include <complex>
#include <limits>
#include <type_traits>

Go to the source code of this file.

Namespaces

 jb
 The top-level namespace for the JayBeams library.
 
 jb::testing
 Helper functions and classes to simplify unit tests.
 

Macros

#define JB_TESTING_MAX_DIFFERENCES_PRINTED   8
 

Functions

template<typename value_t , typename std::enable_if< std::is_integral< value_t >::value >::type * = nullptr>
bool jb::testing::check_close_enough (value_t num_a, value_t num_b, int tol)
 Given two numbers of the same integer type check if the difference is within a given tolerance. More...
 
template<typename value_t >
bool jb::testing::check_close_enough (std::complex< value_t > com_a, std::complex< value_t > com_b, int tol=1)
 Given two complex numbers of the same value type check if the difference is within a given tolerance. More...
 
template<typename value_t >
bool jb::testing::check_close_enough (value_t com_a[2], value_t com_b[2], int tol=1)
 Compare complex number (as arrays of size 2) values with some tolerance. More...
 
template<typename floating >
void jb::testing::check_small (floating t, double small)
 Verify that a floating point value is "close enough" to a small number. More...
 
template<typename real >
void jb::testing::check_small (std::complex< real > t, double small)
 Verify that a complex number is "close enough" to a small number. More...
 
template<typename precision_t >
std::complex< precision_t > jb::testing::format (precision_t v[2])
 Wrap FFTW-style complex numbers in std::complex for iostreaming. More...
 
template<typename value_type >
value_type jb::testing::format (value_type t)
 Allow generic treatment of FFTW-style complex numbers and other types. More...
 
template<typename real , typename std::enable_if< std::is_floating_point< real >::value >::type * = nullptr>
real jb::testing::relative_error (real actual, real expected)
 Calculate the relative error between two float point numbers. More...
 
template<typename integral , typename std::enable_if< std::is_integral< integral >::value >::type * = nullptr>
integral jb::testing::relative_error (integral actual, integral expected)
 Adapt relative_error() for integral numbers. More...
 
template<typename real >
real jb::testing::relative_error (std::complex< real > actual, std::complex< real > expected)
 Calculate the relative error between two complex numbers. More...
 
template<typename real >
real jb::testing::relative_error (real actual[2], real expected[2])
 Calculate the relative error between two complex numbers in FFTW representation. More...
 
template<typename collection_t >
bool jb::testing::check_collection_close_enough (collection_t const &a, collection_t const &b, int tol=1, int max_differences_printed=JB_TESTING_MAX_DIFFERENCES_PRINTED)
 Given two collections of numbers of the same value type, find the differences that are out of a given tolerance and report them via Boost.Test functions. More...
 
template<typename T , std::size_t K>
bool jb::testing::check_collection_close_enough (boost::multi_array< T, K > const &a, boost::multi_array< T, K > const &b, int tol=1, int max_differences_printed=JB_TESTING_MAX_DIFFERENCES_PRINTED)
 Specialization for boost::multi_array type. More...
 
template<typename value_t >
bool jb::testing::check_collection_close_enough (std::size_t size, value_t const *a, value_t const *b, int tol=1, int max_differences_printed=JB_TESTING_MAX_DIFFERENCES_PRINTED)
 Given two collections of integers, floating point or complex numbers find the differences that are out of a given tolerance and report them via Boost.Test functions. More...
 

Macro Definition Documentation

◆ JB_TESTING_MAX_DIFFERENCES_PRINTED

#define JB_TESTING_MAX_DIFFERENCES_PRINTED   8

Definition at line 15 of file check_close_enough.hpp.