Skip to content

Commit

Permalink
Trigonometrics with Pi arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Sep 6, 2023
1 parent 586f4d2 commit cc1b64c
Show file tree
Hide file tree
Showing 16 changed files with 869 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
#include <kyosu/functions/conj.hpp>
#include <kyosu/functions/cos.hpp>
#include <kyosu/functions/cosh.hpp>
#include <kyosu/functions/cospi.hpp>
#include <kyosu/functions/cot.hpp>
#include <kyosu/functions/cotpi.hpp>
#include <kyosu/functions/coth.hpp>
#include <kyosu/functions/convert.hpp>
#include <kyosu/functions/csc.hpp>
#include <kyosu/functions/cscpi.hpp>
#include <kyosu/functions/csch.hpp>
#include <kyosu/functions/dec.hpp>
#include <kyosu/functions/dist.hpp>
Expand Down Expand Up @@ -75,16 +78,20 @@
#include <kyosu/functions/rec.hpp>
#include <kyosu/functions/reldist.hpp>
#include <kyosu/functions/sec.hpp>
#include <kyosu/functions/secpi.hpp>
#include <kyosu/functions/sech.hpp>
#include <kyosu/functions/sign.hpp>
#include <kyosu/functions/sin.hpp>
#include <kyosu/functions/sincos.hpp>
#include <kyosu/functions/sinpi.hpp>
#include <kyosu/functions/sinpicospi.hpp>
#include <kyosu/functions/sinh.hpp>
#include <kyosu/functions/sinhcosh.hpp>
#include <kyosu/functions/sqr_abs.hpp>
#include <kyosu/functions/sqr.hpp>
#include <kyosu/functions/sqrt.hpp>
#include <kyosu/functions/tan.hpp>
#include <kyosu/functions/tanpi.hpp>
#include <kyosu/functions/tanh.hpp>
#include <kyosu/functions/trunc.hpp>

Expand Down
74 changes: 74 additions & 0 deletions include/kyosu/functions/cospi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_cospi : eve::elementwise
{
using callable_tag_type = callable_cospi;

KYOSU_DEFERS_CALLABLE(cospi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cospi(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_cospi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cospi
//! @brief Computes the cosine of the argument in \f$\pi\f$ mutiples.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr T cospi(T z) noexcept;
//! template<eve::ordered_value T> constexpr T cospi(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the cosine of the argument in \f$\pi\f$ mutiples.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cospi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cospi cospi = {};
}
74 changes: 74 additions & 0 deletions include/kyosu/functions/cotpi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_cotpi : eve::elementwise
{
using callable_tag_type = callable_cotpi;

KYOSU_DEFERS_CALLABLE(cotpi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cotpi(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_cotpi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cotpi
//! @brief Computes the cotangent of the argument in \f$\pi\f$ mutiples.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr T cotpi(T z) noexcept;
//! template<eve::ordered_value T> constexpr T cotpi(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the cotangent of the argument in \f$\pi\f$ mutiples.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cotpi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cotpi cotpi = {};
}
74 changes: 74 additions & 0 deletions include/kyosu/functions/cscpi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_cscpi : eve::elementwise
{
using callable_tag_type = callable_cscpi;

KYOSU_DEFERS_CALLABLE(cscpi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cscpi(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_cscpi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cscpi
//! @brief Computes the cosecant of the argument in \f$\pi\f$ mutiples.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr T cscpi(T z) noexcept;
//! template<eve::ordered_value T> constexpr T cscpi(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the cosecant of the argument in \f$\pi\f$ mutiples.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cscpi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cscpi cscpi = {};
}
74 changes: 74 additions & 0 deletions include/kyosu/functions/secpi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_secpi : eve::elementwise
{
using callable_tag_type = callable_secpi;

KYOSU_DEFERS_CALLABLE(secpi_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::secpi(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_secpi(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var secpi
//! @brief Computes the secant of the argument in \f$\pi\f$ mutiples.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr T secpi(T z) noexcept;
//! template<eve::ordered_value T> constexpr T secpi(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the secant of the argument in \f$\pi\f$ mutiples.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/secpi.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_secpi secpi = {};
}
Loading

0 comments on commit cc1b64c

Please sign in to comment.