Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cayley/bessel4 #38

Merged
merged 17 commits into from
Nov 3, 2023
7 changes: 7 additions & 0 deletions include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
#include <kyosu/functions/cyl_bessel_j1.hpp>
#include <kyosu/functions/cyl_bessel_jn.hpp>
#include <kyosu/functions/cyl_bessel_y0.hpp>
#include <kyosu/functions/cyl_bessel_y1.hpp>
#include <kyosu/functions/cyl_bessel_yn.hpp>
#include <kyosu/functions/cyl_bessel_h1n.hpp>
#include <kyosu/functions/cyl_bessel_h2n.hpp>
#include <kyosu/functions/cyl_bessel_k0.hpp>
#include <kyosu/functions/cyl_bessel_k1.hpp>
#include <kyosu/functions/cyl_bessel_kn.hpp>
#include <kyosu/functions/dec.hpp>
#include <kyosu/functions/deta.hpp>
#include <kyosu/functions/digamma.hpp>
Expand Down
77 changes: 77 additions & 0 deletions include/kyosu/functions/cyl_bessel_h1n.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright: KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>
#include <eve/module/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_h1n_);

template<eve::ordered_value N, eve::floating_ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, N n, T const& z) noexcept
{
using e_t = eve::element_type_t<T>;
return complex(cyl_bessel_jn(n, z), cyl_bessel_yn(n, z));
}

template<typename N, typename T>
KYOSU_FORCEINLINE auto operator()(N const & target0, T const& target1) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1))
{
return eve::tag_invoke(*this, target0, target1);
}

template<typename... T>
eve::unsupported_call<callable_cyl_bessel_h1n(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @brief Computes the Bessel/Hankel functions of the third kind ,
//! \f$ H_n^{(1)}\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_h1n(int n, T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr auto cyl_bessel_h1n(int n, T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * return \f$H_n^{(1)}(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_h1n.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_h1n cyl_bessel_h1n = {};
}
77 changes: 77 additions & 0 deletions include/kyosu/functions/cyl_bessel_h2n.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright: KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>
#include <eve/module/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_h2n_);

template<eve::ordered_value N, eve::floating_ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, N n, T const& z) noexcept
{
using e_t = eve::element_type_t<T>;
return complex(cyl_bessel_jn(n, z), -cyl_bessel_yn(n, z));
}

template<typename N, typename T>
KYOSU_FORCEINLINE auto operator()(N const & target0, T const& target1) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1))
{
return eve::tag_invoke(*this, target0, target1);
}

template<typename... T>
eve::unsupported_call<callable_cyl_bessel_h2n(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @brief Computes the Bessel/Hankel functions of the third kind ,
//! \f$ H_n^{(2)}\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_h2n(int n, T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr auto cyl_bessel_h2n(int n, T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * return \f$H_n^{(2)}(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_h2n.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_h2n cyl_bessel_h2n = {};
}
73 changes: 73 additions & 0 deletions include/kyosu/functions/cyl_bessel_k0.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright: KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>
#include <eve/module/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_k0_);

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cyl_bessel_k0
//! @brief Computes the Bessel function of the second kind,
//! \f$ K_0(x)\f$ extended to the complex plane and cayley_dickson values.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_k0(T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr auto cyl_bessel_k0(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * return the cylindrical \f$K_0(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_k0.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_k0 cyl_bessel_k0 = {};
}
73 changes: 73 additions & 0 deletions include/kyosu/functions/cyl_bessel_k1.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright: KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>
#include <eve/module/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_k1_);

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cyl_bessel_k1
//! @brief Computes the Bessel function of the second kind,
//! \f$ K_1(x)\f$ extended to the complex plane and cayley_dickson values.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_k1(T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr auto cyl_bessel_k1(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * return the cylindrical \f$K_1(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_k1.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_k1 cyl_bessel_k1 = {};
}
79 changes: 79 additions & 0 deletions include/kyosu/functions/cyl_bessel_kn.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright: KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>
#include <eve/module/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_kn_);

template<eve::ordered_value N, eve::floating_ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, N n, T const& v) noexcept { return eve::cyl_bessel_kn(n, v); }

template<typename N, typename T>
KYOSU_FORCEINLINE auto operator()(N const & target0, T const& target1) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1))
{
return eve::tag_invoke(*this, target0, target1);
}

template<typename... T>
eve::unsupported_call<callable_cyl_bessel_kn(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @brief Computes the Bessel functions of the first kind,
//! \f$ J_{n}(x)=\sum_{p=0}^{\infty}{\frac{(-1)^p}{p!\,\Gamma (p+n +1)}}
//! {\left({x \over 2}\right)}^{2p+n }\f$.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+(x^2-n^2)y=0\f$ for which
//! \f$ y(0) = 0\f$ if \f$n \ne 0\f$ else \f$1\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_kn(int n, T z) noexcept;
//! template<eve::floating_ordered_value N, eve::floating_ordered_value T> constexpr T cyl_bessel_kn(N n, T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * return the cylindrical \f$J_n(z)\f$.
//!
//! @warning Up to now the cayley_dickson versions have only been imlemented dor scalar int values of n.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_kn.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_kn cyl_bessel_kn = {};
}
Loading