Skip to content

Commit

Permalink
Complex inverse trigonometry
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Sep 11, 2023
1 parent 03915e5 commit d1cd9bb
Show file tree
Hide file tree
Showing 33 changed files with 2,785 additions and 15 deletions.
97 changes: 97 additions & 0 deletions include/kyosu/complex/acos.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//======================================================================================================================
/*
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_acos : eve::elementwise
{
using callable_tag_type = callable_acos;

KYOSU_DEFERS_CALLABLE(acos_);

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acos
//! @brief Computes the acosine of the argument.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acos(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acos(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 [elementwise](@ref glossary_elementwise) the complex principal value
//! of the arc cosine of the input.
//! Branch cuts exist outside the interval \f$[-1, +1]\f$ along the real axis.
//!
//! * for every z: eve::acos(eve::conj(z)) == eve::conj(std::acos(z))
//! * If z is \f$\pm0\f$, the result is \f$\pi/2\f$
//! * If z is \f$i NaN\f$, the result is \f$\pi/2+ i NaN\f$
//! * If z is \f$x+i\infty\f$ (for any finite x), the result is \f$\pi/2-i\infty\f$
//! * If z is \f$x+i NaN\f$ (for any nonzero finite x), the result is \f$NaN+i NaN\f$.
//! * If z is \f$-\infty+i y\f$ (for any positive finite y), the result is \f$\pi-i\infty\f$
//! * If z is \f$+\infty+i y\f$ (for any positive finite y), the result is \f$+0-i\infty\f$
//! * If z is \f$-\infty+i +\infty\f$, the result is \f$3\pi/4-i\infty\f$
//! * If z is \f$\infty+i +\infty\f$, the result is \f$\pi/4-i\infty\f$
//! * If z is \f$\pm\infty+i NaN\f$, the result is \f$NaN \pm i\infty\f$ (the sign
//! of the imaginary part is unspecified)
//! * If z is \f$NaN+i y\f$ (for any finite y), the result is \f$NaN+i NaN\f$
//! * If z is \f$NaN+i\infty\f$, the result is \f$NaN-i\infty\f$
//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acos.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acos acos = {};
}
96 changes: 96 additions & 0 deletions include/kyosu/complex/acosh.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//======================================================================================================================
/*
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_acosh : eve::elementwise
{
using callable_tag_type = callable_acosh;

KYOSU_DEFERS_CALLABLE(acosh_);

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acosh
//! @brief Computes the acoshine of the argument.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acosh(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acosh(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 the complex arc hyperbolic sine of z, in the range of a half-strip mathematically
//! unbounded along the real axis and in the interval \f$i\times[-\pi/2, \pi/2]\f$ along
//! the imaginary axis.
//!
//! * for every z: eve::acosh(eve::conj(z)) == eve::conj(std::acosh(z))
//! * for every z: eve::acosh(-z) == -eve::acosh(z)
//! * If z is \f$+0\f$, the result is \f$+0\f$
//! * If z is \f$NaN\f$, the result is \f$NaN\f$
//! * If z is \f$+1\f$, the result is \f$+\infty\f$
//! * If z is \f$x+i \infty\f$ (for any finite positive x), the result is \f$+0,\pi/2\f$
//! * If z is \f$x+i NaN\f$ (for any finite nonzero x), the result is \f$NaN+i NaN\f$
//! * If z is \f$+\infty+i y\f$ (for any finite positive y), the result is \f$i \pi/2\f$
//! * If z is \f$+\infty+i \infty\f$, the result is \f$i \pi/2\f$
//! * If z is \f$+\infty+i NaN\f$, the result is \f$i NaN\f$
//! * If z is \f$NaN+i y\f$ (for any finite y), the result is \f$NaN+i NaN\f$
//! * If z is \f$NaN+i \infty\f$, the result is \f$i \pi/2\f$ (the sign of the real part is unspecified)
//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acosh.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acosh acosh = {};
}
81 changes: 81 additions & 0 deletions include/kyosu/complex/acot.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//======================================================================================================================
/*
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_acot : eve::elementwise
{
using callable_tag_type = callable_acot;

KYOSU_DEFERS_CALLABLE(acot_);

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acot
//! @brief Computes the acotine of the argument.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acot(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acot(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 [elementwise](@ref glossary_elementwise) the complex principal value
//! of the arc cotangent of the input as the arc tangent of the inverse of the input.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acot.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acot acot = {};
}
80 changes: 80 additions & 0 deletions include/kyosu/complex/acoth.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_acoth : eve::elementwise
{
using callable_tag_type = callable_acoth;

KYOSU_DEFERS_CALLABLE(acoth_);

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var acoth
//! @brief Computes the acothine of the argument.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::ordered_value T> constexpr auto acoth(T z) noexcept; //1
//! template<kyosu::concepts::complex T> constexpr auto acoth(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 the complex arc hyperbolic cotangent of z, computed as \f$\mathop{\mathrm{atanh}}(1/z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/acoth.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_acoth acoth = {};
}
Loading

0 comments on commit d1cd9bb

Please sign in to comment.