-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor changes to quaternions docs and purepart implementation
- Loading branch information
Showing
8 changed files
with
203 additions
and
36 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
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,70 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/detail/overload.hpp> | ||
|
||
namespace eve | ||
{ | ||
//================================================================================================ | ||
//! @addtogroup quaternion | ||
//! @{ | ||
//! @var purepart | ||
//! | ||
//! @brief Callable object computing purepart part of values. | ||
//! | ||
//! **Defined in header** `#include <eve/module/quaternion.hpp>` | ||
//! | ||
//! #### Members Functions | ||
//! | ||
//! | Member | Effect | | ||
//! |:-------------|:-----------------------------------------------------------| | ||
//! | `operator()` | the computation of purepart part | | ||
//! | ||
//! --- | ||
//! | ||
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} | ||
//! auto operator()(value auto x) const noexcept; | ||
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
//! | ||
//! **Parameters** | ||
//! | ||
//!`x`: [value](@ref eve::value). | ||
//! | ||
//! **Return value** | ||
//! 0 if `x` is real, imag(x) if x is an instance of eve::complex, | ||
//! or the purepart (second component) of `x` | ||
//! if x is an instance of eve::quaternion. | ||
//! | ||
//! #### Example | ||
//! | ||
//! @godbolt{doc/quaternion/regular/purepart.cpp} | ||
//! | ||
//! @} | ||
//================================================================================================ | ||
|
||
namespace tag { struct purepart_; } | ||
template<> struct supports_conditional<tag::purepart_> : std::false_type {}; | ||
|
||
EVE_MAKE_CALLABLE(purepart_, purepart); | ||
|
||
namespace detail | ||
{ | ||
template<value V> | ||
EVE_FORCEINLINE auto purepart_( EVE_SUPPORTS(cpu_), V const& ) noexcept | ||
{ | ||
return std::array<V, 3>{0, 0, 0}; | ||
} | ||
|
||
template<value V> | ||
EVE_FORCEINLINE auto purepart_( EVE_SUPPORTS(cpu_), eve::complex<V> const & z) noexcept | ||
{ | ||
return std::array<V, 3>{imag(z), 0, 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
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,48 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
**/ | ||
//================================================================================================== | ||
#include "test.hpp" | ||
#include <eve/module/quaternion.hpp> | ||
|
||
TTS_CASE_WITH( "Check behavior of purepart on scalar" | ||
, tts::bunch<eve::test::scalar::ieee_reals> | ||
, tts::generate ( tts::randoms(eve::valmin, eve::valmax) | ||
, tts::randoms(eve::valmin, eve::valmax) | ||
, tts::randoms(eve::valmin, eve::valmax) | ||
, tts::randoms(eve::valmin, eve::valmax) | ||
) | ||
) | ||
<typename T>(T const& a0, T const& a1, T const& a2, T const& a3) | ||
{ | ||
using e_t = typename T::value_type; | ||
for(size_t i = 0; i < a0.size(); ++i) | ||
{ | ||
auto a = eve::purepart(eve::quaternion<e_t>(a0[i],a1[i],a2[i],a3[i])); | ||
TTS_EQUAL( a1[i], get<0>(a) ); | ||
TTS_EQUAL( a2[i], get<1>(a) ); | ||
TTS_EQUAL( a3[i], get<2>(a) ); | ||
} | ||
}; | ||
|
||
TTS_CASE_WITH( "Check behavior of purepart on wide" | ||
, eve::test::simd::ieee_reals | ||
, tts::generate ( tts::randoms(eve::valmin, eve::valmax) | ||
, tts::randoms(eve::valmin, eve::valmax) | ||
, tts::randoms(eve::valmin, eve::valmax) | ||
, tts::randoms(eve::valmin, eve::valmax) | ||
) | ||
) | ||
<typename T>(T const& a0, T const& a1, T const& a2, T const& a3 ) | ||
{ | ||
using e_t = typename T::value_type; | ||
using z_t = eve::wide<eve::quaternion<e_t>, typename T::cardinal_type>; | ||
|
||
auto a = eve::purepart(z_t(a0,a1,a2,a3)); | ||
TTS_EQUAL( a1, get<0>(a)); | ||
TTS_EQUAL( a2, get<1>(a)); | ||
TTS_EQUAL( a3, get<2>(a)); | ||
}; |