Skip to content

Commit

Permalink
Fix dist/reldist usage in tts adaptors
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Aug 21, 2023
1 parent 49841a7 commit 779307f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,14 @@ int main(int argc, char const **argv)
namespace tts
{

template<kyosu::concepts::complex T> auto relative_distance(T const &l, T const &r)
template<kyosu::concepts::cayley_dickson T> double relative_distance(T const &l, T const &r)
{
auto [rl,il] = l;
auto [rr,ir] = r;

return eve::max(relative_distance(rl,rr), relative_distance(il,ir));
return kyosu::reldist(l,r);
}

template<kyosu::concepts::complex T> auto absolute_distance(T const &l, T const &r)
template<kyosu::concepts::cayley_dickson T> double absolute_distance(T const &l, T const &r)
{
return eve::maximum(eve::dist(l, r));
return kyosu::dist(l, r);
}

template<typename T, typename N>
Expand All @@ -109,6 +106,7 @@ namespace tts

return max_ulp;
}

template<typename T, typename N>
inline double relative_distance(eve::wide<T, N> const &l, eve::wide<T, N> const &r)
{
Expand Down
4 changes: 2 additions & 2 deletions test/unit/function/sqr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TTS_CASE_WITH ( "Check kyosu::sqr over complex"
(auto r, auto i)
{
auto c = kyosu::to_complex(r,i);
TTS_EXPECT(eve::all(kyosu::reldist(kyosu::sqr(c), c*c) <= 0.0001));
TTS_RELATIVE_EQUAL(kyosu::sqr(c), c*c, 1e-7);
};

TTS_CASE_WITH ( "Check kyosu::sqr over quaternion"
Expand All @@ -37,5 +37,5 @@ TTS_CASE_WITH ( "Check kyosu::sqr over quaternion"
{
using type = kyosu::as_quaternion_t<T>;
auto q = type(r,i,j,k);
TTS_EXPECT(eve::all(kyosu::reldist(kyosu::sqr(q), q*q) <= 0.0001));
TTS_RELATIVE_EQUAL(kyosu::sqr(q), q*q, 1e-7);
};

0 comments on commit 779307f

Please sign in to comment.