Skip to content

Commit

Permalink
ik
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Dec 11, 2023
1 parent b8e3381 commit 45f628b
Show file tree
Hide file tree
Showing 10 changed files with 609 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
#include <kyosu/functions/cyl_bessel_h1.hpp>
#include <kyosu/functions/cyl_bessel_h2.hpp>
#include <kyosu/functions/cyl_bessel_h12.hpp>
#include <kyosu/functions/cyl_bessel_i.hpp>
#include <kyosu/functions/cyl_bessel_k.hpp>
#include <kyosu/functions/cyl_bessel_ik.hpp>

#include <kyosu/functions/dec.hpp>
#include <kyosu/functions/deta.hpp>
Expand Down
95 changes: 95 additions & 0 deletions include/kyosu/functions/cyl_bessel_i.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//======================================================================================================================
/*
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_i: eve::elementwise
{
using callable_tag_type = callable_cyl_bessel_i;

KYOSU_DEFERS_CALLABLE(cyl_bessel_i_);

template<eve::floating_scalar_value N, eve::floating_ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, N nu, T const& v) noexcept
{
auto fnu = callable_cyl_bessel_i{};
return fnu(nu, complex(v));
}

template<eve::floating_scalar_value N, eve::floating_ordered_value T, typename R>
static KYOSU_FORCEINLINE auto deferred_call(auto, N nu, T const& v, R& is) noexcept
{
auto fnu = callable_cyl_bessel_i{};
return fnu(nu, complex(v), is);
}

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 N, typename T, typename R>
KYOSU_FORCEINLINE auto operator()(N const & target0, T const& target1, R & out0) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1, out0))
{
return eve::tag_invoke(*this, target0, target1, out0);
}

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cyl_bessel_i
//! @brief Computes the Modified Bessel functions of the first kind.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::floating_ordered_value, kyosu::concepts::cayley_dickson T>
//! constexpr auto cyl_bessel_i(N nu, T z) noexcept;
//!
//! template<eve::floating_ordered_value, eve::floating_ordered_value T>
//! constexpr T cyl_bessel_i(N n, T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `nu`: order of the function.
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * returns \f$I_\nu(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_i.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_i cyl_bessel_i = {};
}
97 changes: 97 additions & 0 deletions include/kyosu/functions/cyl_bessel_ik.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/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_ik_);

template<eve::floating_scalar_value N, eve::floating_ordered_value T, typename R>
static KYOSU_FORCEINLINE auto deferred_call(auto, N nu, T const& v, R& js, R& ys) noexcept
requires(concepts::complex<decltype(js[0])> && concepts::complex<decltype(ys[0])>)
{
auto fnu = callable_cyl_bessel_ik{};
return fnu(nu, complex(v), js, ys);
}

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

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cyl_bessel_ikr
//! @brief Computes the Bessel functions of the first kind J and Y,
//! \f$ J_{\nu}(x)=\sum_{p=0}^{\infty}{\frac{(-1)^p}{p!\,\Gamma (p+\nu +1)}}
//! {\left({x \over 2}\right)}^{2p+\nu }\f$
//! extended to the complex plane.
//!
//! It is the solution of \f$ x^{2}y''+xy'+(x^2-\nu^2)y=0\f$ for which
//! \f$ y(0) = 0\f$ if \f$\nu \ne 0\f$ else \f$1\f$.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::floating_scalar_ordered_value N, eve::floating_ordered_value T, complexRange R>
//! constexpr auto cyl_bessel_ikr(N nu, T z, R& js, R& ys) noexcept;
//!
//! template<eve::floating_scalar_ordered_value N, conceots::kyosu::complex Z, complexRange R>
//! constexpr T cyl_bessel_ikr(N n, Z z, R& js, R& ys) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `nu`: scalar order of the function not necessarily integral.
//! * `z`: Value to process.
//! * `js: range able to contain int(nu)+1 complex values (of type complex_t<T> or Z respectively)
//! * `ys: range able to contain int(nu)+1 complex values (of type complex_t<T> or Z respectively)
//!
//! **Return value**
//!
//! * returns the kumi pair \f$\{J_\nu(z), Y_\nu(z)\}f$ of complex values.
//!
//! *Ouput values
//!
//! * on output js contains the values of \f$((J_{\nu_0+i})_{i = 0\cdot n}\f$
//! * on output ys contains the values of \f$((Y_{\nu_0+i})_{i = 0\cdot n}\f$
//!
//! where \f$\nu_0\f$ is the fractional part of \f$\nu\f$ (\f$0 \le\nu_0\lt 0\f$ and \f$\nu = \nu_0+n\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_ikr.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_ik cyl_bessel_ik = {};
}
14 changes: 14 additions & 0 deletions include/kyosu/functions/cyl_bessel_j.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,27 @@ namespace kyosu::tags
return fnu(nu, complex(v));
}

template<eve::floating_scalar_value N, eve::floating_ordered_value T, typename R>
static KYOSU_FORCEINLINE auto deferred_call(auto, N nu, T const& v, R& js) noexcept
{
auto fnu = callable_cyl_bessel_j{};
return fnu(nu, complex(v), js);
}

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 N, typename T, typename R>
KYOSU_FORCEINLINE auto operator()(N const & target0, T const& target1, R & out0) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1, out0))
{
return eve::tag_invoke(*this, target0, target1, out0);
}

template<typename... T>
eve::unsupported_call<callable_cyl_bessel_j(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
Expand Down
96 changes: 96 additions & 0 deletions include/kyosu/functions/cyl_bessel_k.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/bessel.hpp>

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

KYOSU_DEFERS_CALLABLE(cyl_bessel_k_);

template<eve::floating_scalar_value N, eve::floating_ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, N nu, T const& v) noexcept
{
auto fnu = callable_cyl_bessel_k{};
return fnu(nu, complex(v));
}


template<eve::floating_scalar_value N, eve::floating_ordered_value T, typename R>
static KYOSU_FORCEINLINE auto deferred_call(auto, N nu, T const& v, R& ks) noexcept
{
auto fnu = callable_cyl_bessel_k{};
return fnu(nu, complex(v), ks);
}

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 N, typename T, typename R>
KYOSU_FORCEINLINE auto operator()(N const & target0, T const& target1, R & out0) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1, out0))
{
return eve::tag_invoke(*this, target0, target1, out0);
}

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

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var cyl_bessel_k
//! @brief Computes the Modified Bessel functions of the second kind.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<eve::floating_ordered_value, kyosu::concepts::cayley_dickson T>
//! constexpr auto cyl_bessel_k(N nu, T z) noexcept;
//!
//! template<eve::floating_ordered_value, eve::floating_ordered_value T>
//! constexpr T cyl_bessel_k(N n, T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `nu`: order of the function.
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * returns \f$K_\nu(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_k.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_k cyl_bessel_k = {};
}
1 change: 1 addition & 0 deletions include/kyosu/types/impl/bessel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <kyosu/types/impl/bessel/sb_ikn.hpp>
#include <kyosu/types/impl/besselr/cb_jyr.hpp>
#include <kyosu/types/impl/besselr/cb_h.hpp>
#include <kyosu/types/impl/besselr/cb_ikr.hpp>

// bessels of floating (real) order
// #include <kyosu/types/impl/detail/bessel_jyr.hpp>
Expand Down
Loading

0 comments on commit 45f628b

Please sign in to comment.