-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
258 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_dist : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_dist; | ||
|
||
KYOSU_DEFERS_CALLABLE(dist_); | ||
|
||
static KYOSU_FORCEINLINE auto deferred_call(auto | ||
, eve::ordered_value auto const& v0 | ||
, eve::ordered_value auto const& v1) noexcept | ||
{ | ||
return eve::dist(v0, v1); | ||
} | ||
|
||
KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1 ) const noexcept | ||
-> decltype(eve::tag_invoke(*this, target0, target1)) | ||
{ | ||
return eve::tag_invoke(*this, target0, target1); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_dist(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var dist | ||
//! @brief Computes the distance of the two parameters. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T0, kyosu::concepts::cayley_dickson T1 > constexpr auto dist(T0 z0, T1, z1) noexcept; | ||
//! template<eve::ordered_value T0, kyosu::concepts::cayley_dickson T1> > constexpr auto dist(T0 z0, T1, z1) noexcept; | ||
//! template<kyosu::concepts::cayley_dickson T0, eve::ordered_value T1 > constexpr auto dist(T0 z0, T1, z1) noexcept; | ||
//! template<eve::ordered_value T0, ordered_value T1> > constexpr auto dist(T0 z0, T1, z1) noexcept; | ||
///! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z0, z1` : Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns the absolute value of the arguments difference. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/dist.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_dist dist = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_reldist : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_reldist; | ||
|
||
KYOSU_DEFERS_CALLABLE(reldist_); | ||
|
||
|
||
static KYOSU_FORCEINLINE auto deferred_call(auto | ||
, eve::ordered_value auto const& v0 | ||
, eve::ordered_value auto const& v1) noexcept | ||
{ | ||
return eve::reldist(v0, v1); | ||
} | ||
|
||
KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1 ) const noexcept | ||
-> decltype(eve::tag_invoke(*this, target0, target1)) | ||
{ | ||
return eve::tag_invoke(*this, target0, target1); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_reldist(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var reldist | ||
//! @brief Computes the relative distance of the two parameters. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T0, kyosu::concepts::cayley_dickson T1 > constexpr auto reldist(T0 z0, T1, z1) noexcept; | ||
//! template<eve::ordered_value T0, kyosu::concepts::cayley_dickson T1> > constexpr auto reldist(T0 z0, T1, z1) noexcept; | ||
//! template<kyosu::concepts::cayley_dickson T0, eve::ordered_value T1 > constexpr auto reldist(T0 z0, T1, z1) noexcept; | ||
//! template<eve::ordered_value T0, ordered_value T1> > constexpr auto reldist(T0 z0, T1, z1) noexcept; | ||
///! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z0, z1` : Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! Returns the absolute value of the arguments difference dived by the maximum of their absolute values and 1. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/reldist.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_reldist reldist = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <kyosu/kyosu.hpp> | ||
#include <eve/wide.hpp> | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
using kyosu::dist; | ||
using kyosu::complex; | ||
using kyosu::quaternion; | ||
using e_t = float; | ||
using c_t = complex<float>; | ||
using q_t = quaternion<float>; | ||
|
||
std::cout << "Real: "<< "\n"; | ||
e_t e0(1); | ||
e_t e1(2); | ||
std::cout << e0 << ", " << e1 << " -> " << dist(e0, e1) << "\n"; | ||
|
||
std::cout << "Complex: "<< "\n"; | ||
c_t c0(1, 5); | ||
c_t c1(5, 9); | ||
std::cout << c0 << ", " << c1 << " -> " << dist(c0, c1) << "\n"; | ||
|
||
|
||
|
||
std::cout << "Quaternion: "<< "\n"; | ||
q_t q0(1, 5); | ||
q_t q1(5, 9); | ||
std::cout << q0 << ", " << q1 << " -> " << dist(q0, q1) << "\n"; | ||
|
||
|
||
// std::cout << "SIMD: "; | ||
// using wc_t = eve::wide<complex<double>, eve::fixed<2>>; | ||
// std::cout << wc_t(complex<double>(1.3,-3.7)) << " -> " << dist(wc_t(complex<double>(1.3,-3.7))) << "\n"; | ||
// std::cout << wc_t(complex<double>(1.3,-3.7)) << " -> " << (wc_t(complex<double>(1.3,-3.7)))*(wc_t(complex<double>(1.3,-3.7)))<< "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <kyosu/kyosu.hpp> | ||
#include <eve/wide.hpp> | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
using kyosu::dist; | ||
using kyosu::complex; | ||
using kyosu::quaternion; | ||
using e_t = float; | ||
using c_t = complex<float>; | ||
using q_t = quaternion<float>; | ||
|
||
std::cout << "Real: "<< "\n"; | ||
e_t e0(1); | ||
e_t e1(2); | ||
std::cout << e0 << ", " << e1 << " -> " << dist(e0, e1) << "\n"; | ||
|
||
std::cout << "Complex: "<< "\n"; | ||
c_t c0(1, 5); | ||
c_t c1(4, 9); | ||
std::cout << c0 << ", " << c1 << " -> " << dist(c0, c1) << "\n"; | ||
|
||
|
||
|
||
std::cout << "Quaternion: "<< "\n"; | ||
q_t q0(1, 5, 2, 3); | ||
q_t q1(5, 9, 6, 7); | ||
std::cout << q0 << ", " << q1 << " -> " << dist(q0, q1) << "\n"; | ||
|
||
|
||
std::cout << "SIMD: "<< "\n"; | ||
using wq_t = eve::wide<quaternion<double>, eve::fixed<2>>; | ||
wq_t wq0(1, 5, 2, 3); | ||
wq_t wq1(5, 9, 6, 7); | ||
std::cout << wq0 << ", " << wq1 << " -> " << dist(wq0, wq1) << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters