-
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.
Add cayley-dickson specific constants
- Loading branch information
Showing
32 changed files
with
992 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright : KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
//====================================================================================================================== | ||
//! @defgroup functions Cayley-Dickson constants | ||
//! @brief non real constants | ||
//====================================================================================================================== | ||
#include <kyosu/constants/i.hpp> | ||
#include <kyosu/constants/j.hpp> | ||
#include <kyosu/constants/k.hpp> | ||
#include <kyosu/constants/mi.hpp> | ||
#include <kyosu/constants/cinf.hpp> |
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> | ||
#include <kyosu/types/complex.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_cinf : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_cinf; | ||
|
||
KYOSU_DEFERS_CALLABLE(i_); | ||
|
||
template<eve::value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, as<T> const& ) noexcept | ||
requires(concepts::cayley_dickson<T> || eve::floating_ordered_value<T>) | ||
{ | ||
using u_t = eve::underlying_type_t<T>; | ||
return kyosu::complex(eve::nan(as<u_t>()),eve::inf(as<u_t>())); | ||
} | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_abs(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var i | ||
//! @brief Computes the complex number cinf i.e. complex(nan, inf) in the chosen type. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr as_complex_t<underlying_type_t<T>> cinf(as<T> z) noexcept; | ||
//! template<eve::floating_ordered_value T> constexpr és_complex_t<underlying_type_t<T>> cinf(as<T> z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z`: Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! * always returns a complex scalar value cinf such that real(cinf) is a Nan and imag(cinf) is Inf. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/i.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_cinf cinf = {}; | ||
} |
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,78 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright: KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
#include <kyosu/types/complex.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_i : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_i; | ||
|
||
KYOSU_DEFERS_CALLABLE(i_); | ||
|
||
template<eve::value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, as<T> const& ) noexcept | ||
requires(concepts::cayley_dickson<T> || eve::floating_ordered_value<T>) | ||
{ | ||
using u_t = eve::underlying_type_t<T>; | ||
return kyosu::complex(u_t(0),u_t(1)); } | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_abs(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var i | ||
//! @brief Computes the complex number i i.e. complex(0, 1) in the chosen type. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr as_complex_t<underlying_type_t<T>> i(as<T> z) noexcept; | ||
//! template<eve::floating_ordered_value T> constexpr és_complex_t<underlying_type_t<T>> i(as<T> z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z`: Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! * always returns a complex scalar value i such that real(i) is null and imag(i) is one. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/i.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_i i = {}; | ||
} |
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,78 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright: KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
#include <kyosu/types/complex.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_j : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_j; | ||
|
||
KYOSU_DEFERS_CALLABLE(j_); | ||
|
||
template<eve::value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, as<T> const& ) noexcept | ||
requires(concepts::cayley_dickson<T> || eve::floating_ordered_value<T>) | ||
{ | ||
using u_t = eve::underlying_type_t<T>; | ||
return kyosu::quaternion(u_t(0), u_t(0), u_t(1), u_t(0)); } | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_abs(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var i | ||
//! @brief Computes the complex number j i.e. quaternion(0, 0, 1, 0) in the chosen type. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr as_complex_t<underlying_type_t<T>> j(as<T> z) noexcept; | ||
//! template<eve::floating_ordered_value T> constexpr és_complex_t<underlying_type_t<T>> j(as<T> z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z`: Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! * always returns a quaternion scalar value j such that all parts are null except the jpart whose value is one. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/i.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_j j = {}; | ||
} |
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,78 @@ | ||
//====================================================================================================================== | ||
/* | ||
Kyosu - Complex Without Complexes | ||
Copyright: KYOSU Contributors & Maintainers | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//====================================================================================================================== | ||
#pragma once | ||
|
||
#include <kyosu/details/invoke.hpp> | ||
#include <kyosu/types/complex.hpp> | ||
|
||
namespace kyosu::tags | ||
{ | ||
struct callable_k : eve::elementwise | ||
{ | ||
using callable_tag_type = callable_k; | ||
|
||
KYOSU_DEFERS_CALLABLE(k_); | ||
|
||
template<eve::value T> | ||
static KYOSU_FORCEINLINE auto deferred_call(auto, as<T> const& ) noexcept | ||
requires(concepts::cayley_dickson<T> || eve::floating_ordered_value<T>) | ||
{ | ||
using u_t = eve::underlying_type_t<T>; | ||
return kyosu::quaternion(u_t(0),u_t(0), u_t(0), u_t(1)); } | ||
|
||
template<typename T> | ||
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) | ||
{ | ||
return eve::tag_invoke(*this, target); | ||
} | ||
|
||
template<typename... T> | ||
eve::unsupported_call<callable_abs(T&&...)> operator()(T&&... x) const | ||
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; | ||
}; | ||
} | ||
|
||
namespace kyosu | ||
{ | ||
//====================================================================================================================== | ||
//! @addtogroup functions | ||
//! @{ | ||
//! @var i | ||
//! @brief Computes the complex number k i.e. quaternion(0, 0, 0, 1) in the chosen type. | ||
//! | ||
//! **Defined in Header** | ||
//! | ||
//! @code | ||
//! #include <kyosu/functions.hpp> | ||
//! @endcode | ||
//! | ||
//! @groupheader{Callable Signatures} | ||
//! | ||
//! @code | ||
//! namespace kyosu | ||
//! { | ||
//! template<kyosu::concepts::cayley_dickson T> constexpr as_complex_t<underlying_type_t<T>> k(as<T> z) noexcept; | ||
//! template<eve::floating_ordered_value T> constexpr és_complex_t<underlying_type_t<T>> k(as<T> z) noexcept; | ||
//! } | ||
//! @endcode | ||
//! | ||
//! **Parameters** | ||
//! | ||
//! * `z`: Value to process. | ||
//! | ||
//! **Return value** | ||
//! | ||
//! * always returns a quaternion scalar value k such that all parts are null exceptthe k part whose value is one. | ||
//! | ||
//! @groupheader{Example} | ||
//! | ||
//! @godbolt{doc/i.cpp} | ||
//! @} | ||
//====================================================================================================================== | ||
inline constexpr tags::callable_k k = {}; | ||
} |
Oops, something went wrong.