Skip to content

Commit

Permalink
Arc-trigo and other math functions refurbished
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored Mar 15, 2024
1 parent ca2ad82 commit f2a4f2d
Show file tree
Hide file tree
Showing 58 changed files with 872 additions and 1,485 deletions.
11 changes: 0 additions & 11 deletions include/eve/module/math/pedantic/atan2.hpp

This file was deleted.

27 changes: 0 additions & 27 deletions include/eve/module/math/pedantic/impl/arg.hpp

This file was deleted.

66 changes: 0 additions & 66 deletions include/eve/module/math/pedantic/impl/atan2.hpp

This file was deleted.

34 changes: 0 additions & 34 deletions include/eve/module/math/pedantic/impl/atan2d.hpp

This file was deleted.

33 changes: 0 additions & 33 deletions include/eve/module/math/pedantic/impl/atan2pi.hpp

This file was deleted.

5 changes: 2 additions & 3 deletions include/eve/module/math/pedantic/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
//==================================================================================================
#pragma once

#include <eve/module/math/pedantic/atan2.hpp>
#include <eve/module/math/pedantic/atan2d.hpp>
#include <eve/module/math/pedantic/atan2pi.hpp>
// #include <eve/module/math/pedantic/atan2d.hpp>
// #include <eve/module/math/pedantic/atan2pi.hpp>
#include <eve/module/math/pedantic/horner.hpp>
#include <eve/module/math/pedantic/lpnorm.hpp>
#include <eve/module/math/pedantic/reverse_horner.hpp>
29 changes: 14 additions & 15 deletions include/eve/module/math/regular/acosd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

namespace eve
{
template<typename Options>
struct acosd_t : elementwise_callable<acosd_t, Options, raw_option>
{
template<eve::floating_ordered_value T>
constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }
template<typename Options>
struct acosd_t : elementwise_callable<acosd_t, Options, raw_option>
{
template<eve::floating_ordered_value T>
constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }

EVE_CALLABLE_OBJECT(acosd_t, acosd_);
};
EVE_CALLABLE_OBJECT(acosd_t, acosd_);
};
//================================================================================================
//! @addtogroup math_invtrig
//! @{
Expand Down Expand Up @@ -66,15 +66,14 @@ struct acosd_t : elementwise_callable<acosd_t, Options, raw_option>
//! @godbolt{doc/math/regular/acosd.cpp}
//! @}
//================================================================================================
inline constexpr auto acosd = functor<acosd_t>;
inline constexpr auto acosd = functor<acosd_t>;

namespace detail
{
template<typename T, callable_options O>
constexpr EVE_FORCEINLINE T acosd_(EVE_REQUIRES(cpu_), O const& o, T const& a0)
namespace detail
{
if constexpr( has_native_abi_v<T> ) return radindeg(acos[o](a0));
else return apply_over(acosd[o], a0);
template<typename T, callable_options O>
constexpr EVE_FORCEINLINE T acosd_(EVE_REQUIRES(cpu_), O const& o, T const& a0)
{
return radindeg(acos[o](a0));
}
}
}
}
49 changes: 38 additions & 11 deletions include/eve/module/math/regular/acosh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@
//==================================================================================================
#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.hpp>
#include <eve/module/math/constant/inv_2eps.hpp>
#include <eve/module/math/constant/log_2.hpp>
#include <eve/module/math/regular/log.hpp>
#include <eve/module/math/regular/log1p.hpp>

namespace eve
{
template<typename Options>
struct acosh_t : elementwise_callable<acosh_t, Options>
{
template<eve::floating_ordered_value T>
constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }

EVE_CALLABLE_OBJECT(acosh_t, acosh_);
};

//================================================================================================
//! @addtogroup math_invhyper
//! @{
Expand Down Expand Up @@ -50,22 +66,33 @@ namespace eve
//! * If the element is \f$1\f$, \f$+0\f$ is returned.
//! * If the element is \f$+\infty\f$, \f$+\infty\f$ is returned.
//! * If the element is a `Nan`, `NaN` is returned.
//!
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/math/regular/acosh.cpp}
//!
//! @}
//================================================================================================
namespace tag
{
struct acosh_;
}
inline constexpr auto acosh = functor<acosh_t>;

template<> struct supports_optimized_conversion<tag::acosh_> : std::true_type
{};
namespace detail
{
template<typename T, callable_options O>
constexpr EVE_FORCEINLINE T acosh_(EVE_REQUIRES(cpu_), O const&, T const& x)
{
const T t = dec(x);
auto const test = is_greater(t, inv_2eps(eve::as<T>()));

EVE_MAKE_CALLABLE(acosh_, acosh);
if constexpr( simd_value<T> )
{
const T z = if_else(test, x, t + sqrt(fma(t, t, t + t)));
return add[test](log1p(z), log_2(eve::as<T>()));
}
else if constexpr( scalar_value<T> )
{
if( test ) { return eve::log(t) + log_2(eve::as<T>()); }
else { return eve::log1p(t + eve::sqrt(fma(t, t, t + t))); }
}
}
}
}

#include <eve/module/math/regular/impl/acosh.hpp>
33 changes: 29 additions & 4 deletions include/eve/module/math/regular/acot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@
//==================================================================================================
#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.hpp>
#include <eve/module/math/detail/generic/atan_kernel.hpp>

namespace eve
{
template<typename Options>
struct acot_t : elementwise_callable<acot_t, Options>
{
template<eve::floating_ordered_value T>
constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }

EVE_CALLABLE_OBJECT(acot_t, acot_);
};

//================================================================================================
//! @addtogroup math_invtrig
//! @{
Expand Down Expand Up @@ -53,8 +66,20 @@ namespace eve
//! @godbolt{doc/math/regular/acot.cpp}
//! @}
//================================================================================================
inline constexpr auto acot = functor<acot_t>;

EVE_MAKE_CALLABLE(acot_, acot);
namespace detail
{
template<typename T, callable_options O>
constexpr EVE_FORCEINLINE T acot_(EVE_REQUIRES(cpu_), O const&, T const& a)
{
if constexpr( has_native_abi_v<T> )
{
auto x = eve::abs(a);
return bit_xor(atan_kernel(rec(x), x), bitofsign(a));
}
else
return apply_over(acot, a);
}
}
}

#include <eve/module/math/regular/impl/acot.hpp>
25 changes: 21 additions & 4 deletions include/eve/module/math/regular/acotd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>
#include <eve/arch.hpp>
#include <eve/traits/overload.hpp>
#include <eve/module/core/decorator/core.hpp>

namespace eve
{
template<typename Options>
struct acotd_t : elementwise_callable<acotd_t, Options>
{
template<eve::floating_ordered_value T>
constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); }

EVE_CALLABLE_OBJECT(acotd_t, acotd_);
};

//================================================================================================
//! @addtogroup math_invtrig
//! @{
Expand Down Expand Up @@ -56,8 +67,14 @@ namespace eve
//! @godbolt{doc/math/regular/acotd.cpp}
//! @}
//================================================================================================
inline constexpr auto acotd = functor<acotd_t>;

EVE_MAKE_CALLABLE(acotd_, acotd);
namespace detail
{
template<typename T, callable_options O>
constexpr EVE_FORCEINLINE T acotd_(EVE_REQUIRES(cpu_), O const&, T const& a)
{
return radindeg(acot(a));
}
}
}

#include <eve/module/math/regular/impl/acotd.hpp>
Loading

0 comments on commit f2a4f2d

Please sign in to comment.