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
78 changes: 78 additions & 0 deletions include/kyosu/functions/cyl_bessel_h1n.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//======================================================================================================================
/*
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
//! @{
//! @var cyl_bessel_h1n
//! @brief Computes the Bessel/Hankel functions of the third kind,
//! \f$ H_n^{(1)}(z) = J_n(z)+iY_n(z)\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**
//!
//! * returns \f$H_n^{(1)}(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_h1n.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_h1n cyl_bessel_h1n = {};
}
78 changes: 78 additions & 0 deletions include/kyosu/functions/cyl_bessel_h2n.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//======================================================================================================================
/*
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
//! @{
//! @var cyl_bessel_h2n
//! @brief Computes the Bessel/Hankel functions of the third kind ,
//! \f$ H_n^{(2)} = J_n(z)-iY_n(z)\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 = {};
}
9 changes: 4 additions & 5 deletions include/kyosu/functions/cyl_bessel_i0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ namespace kyosu
//! @addtogroup functions
//! @{
//! @var cyl_bessel_i0
//! @brief Computes the Bessel function of the first kind,
//! \f$ J_0(x)=\frac1{\pi }\int _{0}^{\pi}\cos(x\sin \tau)
//! \,\mathrm {d} \tau \f$ extended to the complex plane and cayley_dickson values.
//! @brief Computes the modified Bessel function of the first kind \f$I_{0}(x)=J_{0}(ix)\f$
//! extended to the complex plane and cayley_dickson algebras.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//! It is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
Expand All @@ -65,7 +64,7 @@ namespace kyosu
//!
//! **Return value**
//!
//! * return the cylindrical \f$J_0(z)\f$.
//! * returns \f$I_0(z)\f$.
//!
//! @groupheader{Example}
//!
Expand Down
9 changes: 4 additions & 5 deletions include/kyosu/functions/cyl_bessel_i1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ namespace kyosu
//! @addtogroup functions
//! @{
//! @var cyl_bessel_i1
//! @brief Computes the Bessel function of the first kind,
//! \f$ J_0(x)=\frac1{\pi }\int _{0}^{\pi}\cos(x\sin \tau)
//! \,\mathrm {d} \tau \f$ extended to the complex plane and cayley_dickson values.
//! @brief Computes the modified Bessel function of the first kind,
//! \f$ I_1(x)= _iJ_1(ix) \f$ extended to the complex plane and cayley_dickson algebras.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//! It is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 0\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
Expand All @@ -65,7 +64,7 @@ namespace kyosu
//!
//! **Return value**
//!
//! * return the cylindrical \f$J_0(z)\f$.
//! * returns \f$I_1(z)\f$.
//!
//! @groupheader{Example}
//!
Expand Down
16 changes: 7 additions & 9 deletions include/kyosu/functions/cyl_bessel_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ 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$.
//! @var cyl_bessel_in
//! @brief Computes the modified Bessel functions of the first kind \f$I_{n}(x)=i^{-n}J_{n }(ix)\f$,
//! extended to the complex plane and cayley_dickson algebras.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+(x^2-n^2)y=0\f$ for which
//! 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
Expand All @@ -55,8 +55,8 @@ namespace kyosu
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_in(int n, T z) noexcept;
//! template<eve::floating_ordered_value N, eve::floating_ordered_value T> constexpr T cyl_bessel_in(N n, T z) noexcept;
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_in(int n, T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr T cyl_bessel_in(int n, T z) noexcept;
//! }
//! @endcode
//!
Expand All @@ -66,9 +66,7 @@ namespace kyosu
//!
//! **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.
//! * returns \f$J_n(z)\f$.
//!
//! @groupheader{Example}
//!
Expand Down
6 changes: 3 additions & 3 deletions include/kyosu/functions/cyl_bessel_j0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ namespace kyosu
//! @var cyl_bessel_j0
//! @brief Computes the Bessel function of the first kind,
//! \f$ J_0(x)=\frac1{\pi }\int _{0}^{\pi}\cos(x\sin \tau)
//! \,\mathrm {d} \tau \f$ extended to the complex plane and cayley_dickson values.
//! \,\mathrm {d} \tau \f$ extended to the complex plane and cayley_dickson algebras.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//! It is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
Expand All @@ -65,7 +65,7 @@ namespace kyosu
//!
//! **Return value**
//!
//! * return the cylindrical \f$J_0(z)\f$.
//! * returns \f$J_0(z)\f$.
//!
//! @groupheader{Example}
//!
Expand Down
5 changes: 2 additions & 3 deletions include/kyosu/functions/cyl_bessel_j1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ namespace kyosu
//! @brief Computes the Bessel function of the first kind,
//! \f$ J_1(x)=\frac1{\pi }\int _{0}^{\pi}\cos(\tau-x\sin \tau )\,\mathrm {d} \tau \f$
//! extended to the complex plane and cayley_dickson values.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//! It is the solution of \f$ x^{2}y''+xy'+x^2y=0\f$ for which \f$ y(0) = 1\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
Expand All @@ -65,7 +64,7 @@ namespace kyosu
//!
//! **Return value**
//!
//! * return the cylindrical \f$J_0(z)\f$.
//! * returns \f$J_0(z)\f$.
//!
//! @groupheader{Example}
//!
Expand Down
14 changes: 7 additions & 7 deletions include/kyosu/functions/cyl_bessel_jn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ namespace kyosu
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cyl_bessel_jn
//! @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$.
//! {\left({x \over 2}\right)}^{2p+n }\f$
//! extended to the complex plane and cayley_dickson values.
//!
//! In the real field, it is the solution of \f$ x^{2}y''+xy'+(x^2-n^2)y=0\f$ for which
//! 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
Expand All @@ -55,8 +57,8 @@ namespace kyosu
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_jn(int n, T z) noexcept;
//! template<eve::floating_ordered_value N, eve::floating_ordered_value T> constexpr T cyl_bessel_jn(N n, T z) noexcept;
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_jn(int n, T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr T cyl_bessel_jn(int n, T z) noexcept;
//! }
//! @endcode
//!
Expand All @@ -66,9 +68,7 @@ namespace kyosu
//!
//! **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.
//! * returns \f$J_n(z)\f$.
//!
//! @groupheader{Example}
//!
Expand Down
Loading