Skip to content

Commit

Permalink
Remaining math functions refurbished
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored Mar 20, 2024
1 parent c9808a4 commit 8e07aec
Show file tree
Hide file tree
Showing 40 changed files with 1,657 additions and 2,424 deletions.
1 change: 0 additions & 1 deletion include/eve/module/core/pedantic/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <eve/module/core/pedantic/is_flint.hpp>
#include <eve/module/core/pedantic/is_not_flint.hpp>
#include <eve/module/core/pedantic/lerp.hpp>
#include <eve/module/core/pedantic/manhattan.hpp>
#include <eve/module/core/pedantic/modf.hpp>
#include <eve/module/core/pedantic/negatenz.hpp>
#include <eve/module/core/pedantic/next.hpp>
Expand Down
100 changes: 0 additions & 100 deletions include/eve/module/core/pedantic/impl/manhattan.hpp

This file was deleted.

11 changes: 0 additions & 11 deletions include/eve/module/core/pedantic/manhattan.hpp

This file was deleted.

65 changes: 0 additions & 65 deletions include/eve/module/core/regular/impl/manhattan.hpp

This file was deleted.

47 changes: 43 additions & 4 deletions include/eve/module/core/regular/manhattan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,32 @@
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>
#include <eve/arch.hpp>
#include <eve/traits/overload.hpp>
#include <eve/module/core/decorator/core.hpp>
#include <eve/module/core/regular/abs.hpp>
#include <eve/module/core/regular/max.hpp>
#include <eve/module/core/regular/is_infinite.hpp>

namespace eve
{
template<typename Options>
struct manhattan_t : tuple_callable<manhattan_t, Options, pedantic_option, saturated_option>
{
template<eve::value T0, eve::value T1, value... Ts>
EVE_FORCEINLINE constexpr common_value_t<T0,T1, Ts...> operator()(T0 t0, T1 t1, Ts...ts) const noexcept
{
return EVE_DISPATCH_CALL(t0, t1, ts...);
}

template<kumi::non_empty_product_type Tup>
EVE_FORCEINLINE constexpr
kumi::apply_traits_t<eve::common_value,Tup>
operator()(Tup const& t) const noexcept requires(kumi::size_v<Tup> >= 2) { return EVE_DISPATCH_CALL(t); }

EVE_CALLABLE_OBJECT(manhattan_t, manhattan_);
};

//================================================================================================
//! @addtogroup core_arithmetic
//! @{
Expand Down Expand Up @@ -69,7 +91,24 @@ namespace eve
//! @godbolt{doc/core/pedantic/manhattan.cpp}
//! @}
//================================================================================================
EVE_MAKE_CALLABLE(manhattan_, manhattan);
}
inline constexpr auto manhattan = functor<manhattan_t>;

#include <eve/module/core/regular/impl/manhattan.hpp>
namespace detail
{
template<typename T0,typename T1, typename... Ts, callable_options O>
EVE_FORCEINLINE constexpr common_value_t<T0, T1, Ts...>
manhattan_(EVE_REQUIRES(cpu_), O const & , T0 a0, T1 a1, Ts... args) noexcept
{
using r_t = common_value_t<T0, T1, Ts...>;
auto r = eve::add/*TODO[o]*/(abs(r_t(a0)), abs(r_t(a1)), abs(r_t(args))...);
if constexpr(O::contains(pedantic2))
{
auto inf_found = is_infinite(r_t(a0)) || is_infinite(r_t(a1));
inf_found = (inf_found || ... || is_infinite(r_t(args)));
return if_else(inf_found, inf(as(r)), r);
}
else
return r;
}
}
}
9 changes: 3 additions & 6 deletions include/eve/module/math/detail/generic/trig_finalize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@

namespace eve
{
EVE_MAKE_CALLABLE(cos_eval_, cos_eval);
EVE_MAKE_CALLABLE(sin_eval_, sin_eval);
EVE_MAKE_CALLABLE(tancot_eval_, tancot_eval);

namespace detail
{
template<floating_ordered_value T>
EVE_FORCEINLINE constexpr auto
cos_eval_(EVE_SUPPORTS(cpu_), T const& z) noexcept
cos_eval(T const& z) noexcept
{
using elt_t = element_type_t<T>;
if constexpr( std::is_same_v<elt_t, float> )
Expand All @@ -47,7 +44,7 @@ namespace eve

template<floating_ordered_value T>
EVE_FORCEINLINE constexpr auto
sin_eval_(EVE_SUPPORTS(cpu_), const T& z, const T& x) noexcept
sin_eval(const T& z, const T& x) noexcept
{
// here T is float or double and x positive
using elt_t = element_type_t<T>;
Expand All @@ -69,7 +66,7 @@ namespace eve

template<floating_ordered_value T>
EVE_FORCEINLINE constexpr auto
tancot_eval_(EVE_SUPPORTS(cpu_), const T& z) noexcept
tancot_eval(const T& z) noexcept
{
// here T is float or double and z positive
T zz = eve::sqr(z);
Expand Down
11 changes: 0 additions & 11 deletions include/eve/module/math/pedantic/geommean.hpp

This file was deleted.

50 changes: 0 additions & 50 deletions include/eve/module/math/pedantic/impl/geommean.hpp

This file was deleted.

49 changes: 0 additions & 49 deletions include/eve/module/math/pedantic/impl/lpnorm.hpp

This file was deleted.

Loading

0 comments on commit 8e07aec

Please sign in to comment.