Skip to content

Commit

Permalink
Implements trigonometric functions in PI unit
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Sep 13, 2023
1 parent d1cd9bb commit 1cc4b88
Show file tree
Hide file tree
Showing 16 changed files with 838 additions and 0 deletions.
80 changes: 80 additions & 0 deletions include/kyosu/complex/acospi.hpp
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>
#include <eve/module/math.hpp>

namespace kyosu::tags
{
struct callable_acospi : eve::elementwise
{
using callable_tag_type = callable_acospi;

KYOSU_DEFERS_CALLABLE(acospi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept
{
auto fn = callable_acospi{};
return fn(v);
}

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_acospi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acospi
//! @brief Computes the arc cosine of the argument times \f$\pi\f$.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acospi(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acospi(T z) noexcept; //2
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! 1. a real input z is treated as if to_complex(z) was entered.
//!
//! 2. Returns `pi(as(z))*acos(z)`
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acospi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acospi acospi = {};
}
80 changes: 80 additions & 0 deletions include/kyosu/complex/acotpi.hpp
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>
#include <eve/module/math.hpp>

namespace kyosu::tags
{
struct callable_acotpi : eve::elementwise
{
using callable_tag_type = callable_acotpi;

KYOSU_DEFERS_CALLABLE(acotpi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept
{
auto fn = callable_acotpi{};
return fn(v);
}

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_acotpi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acotpi
//! @brief Computes the arc cotangent of the argument times \f$\pi\f$.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acotpi(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acotpi(T z) noexcept; //2
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! 1. a real input z is treated as if to_complex(z) was entered.
//!
//! 2. Returns `pi(as(z))*acot(z)`
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acotpi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acotpi acotpi = {};
}
80 changes: 80 additions & 0 deletions include/kyosu/complex/acscpi.hpp
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>
#include <eve/module/math.hpp>

namespace kyosu::tags
{
struct callable_acscpi : eve::elementwise
{
using callable_tag_type = callable_acscpi;

KYOSU_DEFERS_CALLABLE(acscpi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept
{
auto fn = callable_acscpi{};
return fn(v);
}

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_acscpi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acscpi
//! @brief Computes the arc cosecant of the argument times \f$\pi\f$.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acscpi(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acscpi(T z) noexcept; //2
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! 1. a real input z is treated as if to_complex(z) was entered.
//!
//! 2. Returns `pi(as(z))*acsc(z)`
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acscpi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acscpi acscpi = {};
}
80 changes: 80 additions & 0 deletions include/kyosu/complex/asecpi.hpp
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>
#include <eve/module/math.hpp>

namespace kyosu::tags
{
struct callable_asecpi : eve::elementwise
{
using callable_tag_type = callable_asecpi;

KYOSU_DEFERS_CALLABLE(asecpi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept
{
auto fn = callable_asecpi{};
return fn(v);
}

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_asecpi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var asecpi
//! @brief Computes the arc secant of the argument times \f$\pi\f$.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto asecpi(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto asecpi(T z) noexcept; //2
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! 1. a real input z is treated as if to_complex(z) was entered.
//!
//! 2. Returns `pi(as(z))*asec(z)`
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/asecpi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_asecpi asecpi = {};
}
Loading

0 comments on commit 1cc4b88

Please sign in to comment.