Description:
I created a new function called flit::abs_compare(a, b) that does a little more than std::abs(a-b).
If a and b are both NaN with the same sign, return 0.0
If a and b are both inf with the same sign, return 0.0
This is to be a better default comparison function that will not fail if both test and baseline values match (even if they are inf or NaN).
This flit::abs_compare() function is used also from flit::l2norm() to take the difference between elements before taking the square and summing. Therefore, flit::l2norm() also benefits from being able to handle inf and NaN in matching spots within the vector.
I changed data/tests/Empty.cpp to use flit::abs_compare() as the default comparison between long double values.
Documentation:
Added a section in writing-test-cases.md called Default Comparison Details giving these details for both flit::abs_compare() and flit::l2norm().
Tests:
Added tests to tests/flit_src/tst_flitHelpers_h.cpp for flit::abs_compare(), and made more tests for flit::l2norm().
Fixes #133
Description: I created a new function called
flit::abs_compare(a, b)
that does a little more thanstd::abs(a-b)
.a
andb
are bothNaN
with the same sign, return0.0
a
andb
are bothinf
with the same sign, return0.0
This is to be a better default comparison function that will not fail if both test and baseline values match (even if they are
inf
orNaN
).This
flit::abs_compare()
function is used also fromflit::l2norm()
to take the difference between elements before taking the square and summing. Therefore,flit::l2norm()
also benefits from being able to handleinf
andNaN
in matching spots within the vector.I changed
data/tests/Empty.cpp
to useflit::abs_compare()
as the default comparison betweenlong double
values.Documentation: Added a section in
writing-test-cases.md
calledDefault Comparison Details
giving these details for bothflit::abs_compare()
andflit::l2norm()
.Tests: Added tests to
tests/flit_src/tst_flitHelpers_h.cpp
forflit::abs_compare()
, and made more tests forflit::l2norm()
.