Skip to content

Commit

Permalink
Bessel functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Oct 24, 2023
1 parent ea01a29 commit 0d74499
Show file tree
Hide file tree
Showing 65 changed files with 3,627 additions and 1,817 deletions.
54 changes: 24 additions & 30 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,46 +129,40 @@ complex functions and rotation related quaternion usage.

* callables usable with all cayley_dickson types

Most **EVE** arithmetic and math functions are provided.
Most **EVE** arithmetic and math functions are provided. In particular, real analytic functions of one variable
can be quite naturally extended using the polar form described above from a mere complex implementation.

| | | | | |
|--------------|---------------|-----------------|------------|-----------------|
| [abs](@ref kyosu::abs ) | [acos](@ref kyosu::acos ) | [acosh](@ref kyosu::acosh ) | [acospi](@ref kyosu::acospi ) | [acot](@ref kyosu::acot ) |
| [acotpi](@ref kyosu::acotpi ) | [atanpi](@ref kyosu::atanpi ) | [acoth](@ref kyosu::acoth ) | [arg](@ref kyosu::arg ) | [acsc](@ref kyosu::acsc ) |
| [acscpi](@ref kyosu::acscpi ) | [acsch](@ref kyosu::acsch ) | [asec](@ref kyosu::asec ) | [asecpi](@ref kyosu::asecpi ) | [asech](@ref kyosu::asech ) |
| [asin](@ref kyosu::asin ) | [asinpi](@ref kyosu::asinpi ) | [asinh](@ref kyosu::asinh ) | [atan](@ref kyosu::atan ) | [atanh](@ref kyosu::atanh ) |
| [average](@ref kyosu::average ) | [ceil](@ref kyosu::ceil ) | [conj](@ref kyosu::conj ) | [cos](@ref kyosu::cos ) | [cosh](@ref kyosu::cosh ) |
| [cospi](@ref kyosu::cospi ) | [cot](@ref kyosu::cot ) | [cotpi](@ref kyosu::cotpi ) | [coth](@ref kyosu::coth ) | [convert](@ref kyosu::convert ) |
| [csc](@ref kyosu::csc ) | [cscpi](@ref kyosu::cscpi ) | [csch](@ref kyosu::csch ) | [dec](@ref kyosu::dec ) | [dist](@ref kyosu::dist ) |
| [dot](@ref kyosu::dot ) | [exp](@ref kyosu::exp ) | [exp10](@ref kyosu::exp10 ) | [exp2](@ref kyosu::exp2 ) | [exp_i](@ref kyosu::exp_i ) |
| [exp_ipi](@ref kyosu::exp_ipi ) | [expm1](@ref kyosu::expm1 ) | [expmx2](@ref kyosu::expmx2 ) | [expx2](@ref kyosu::expx2 ) | [fam](@ref kyosu::fam ) |
| [floor](@ref kyosu::floor ) | [fma](@ref kyosu::fma ) | [fms](@ref kyosu::fms ) | [fnma](@ref kyosu::fnma ) | [fnms](@ref kyosu::fnms ) |
| [frac](@ref kyosu::frac ) | [fsm](@ref kyosu::fsm ) | [from_polar](@ref kyosu::from_polar ) | [horner](@ref kyosu::horner ) | [hypot](@ref kyosu::hypot ) |
| [if_else](@ref kyosu::if_else ) | [inc](@ref kyosu::inc ) ||||
| [average](@ref kyosu::average ) | [beta](@ref kyosu::beta ) | [ceil](@ref kyosu::ceil ) | [conj](@ref kyosu::conj ) | [cos](@ref kyosu::cos ) |
| [cosh](@ref kyosu::cosh ) | [cospi](@ref kyosu::cospi ) | [cot](@ref kyosu::cot ) | [cotpi](@ref kyosu::cotpi ) | [coth](@ref kyosu::coth ) |
| [convert](@ref kyosu::convert ) | [csc](@ref kyosu::csc ) | [cscpi](@ref kyosu::cscpi ) | [csch](@ref kyosu::csch ) | [dec](@ref kyosu::dec ) |
| [deta](@ref kyosu::deta ) | [digamma](@ref kyosu::digamma ) | [dist](@ref kyosu::dist ) | [dot](@ref kyosu::dot ) | [erf](@ref kyosu::erf ) |
| [erfcx](@ref kyosu::erfcx ) | [erfi](@ref kyosu::erfi ) | [eta](@ref kyosu::eta ) | [exp](@ref kyosu::exp ) | [exp10](@ref kyosu::exp10 ) |
| [exp2](@ref kyosu::exp2 ) | [exp_i](@ref kyosu::exp_i ) | [exp_ipi](@ref kyosu::exp_ipi ) | [expm1](@ref kyosu::expm1 ) | [expmx2](@ref kyosu::expmx2 ) |
| [expx2](@ref kyosu::expx2 ) | [faddeeva](@ref kyosu::faddeeva ) | [fam](@ref kyosu::fam ) | [floor](@ref kyosu::floor ) | [fma](@ref kyosu::fma ) |
| [fms](@ref kyosu::fms ) | [fnma](@ref kyosu::fnma ) | [fnms](@ref kyosu::fnms ) | [frac](@ref kyosu::frac ) | [fsm](@ref kyosu::fsm ) |
| [from_polar](@ref kyosu::from_polar ) | [horner](@ref kyosu::horner ) | [hypot](@ref kyosu::hypot ) | [if_else](@ref kyosu::if_else )| [inc](@ref kyosu::inc ) |
| [ipart](@ref kyosu::ipart ) | [is_denormal](@ref kyosu::is_denormal ) | [is_equal](@ref kyosu::is_equal ) | [is_eqz](@ref kyosu::is_eqz ) | [is_finite](@ref kyosu::is_finite ) |
| [is_infinite](@ref kyosu::is_infinite ) | [is_imag](@ref kyosu::is_imag ) | [is_nan](@ref kyosu::is_nan ) | [is_nez](@ref kyosu::is_nez ) | [is_not_denormal](@ref kyosu::is_not_denormal ) |
| [is_not_equal](@ref kyosu::is_not_equal ) | [is_not_finite](@ref kyosu::is_not_finite ) | [is_not_infinite](@ref kyosu::is_not_finite ) | [is_not_nan](@ref kyosu::is_not_nan ) | [is_not_real](@ref kyosu::is_not_real ) |
| [is_not_equal](@ref kyosu::is_not_equal ) | [is_not_finite](@ref kyosu::is_not_finite ) | [is_not_infinite](@ref kyosu::is_not_finite ) | [is_not_nan](@ref kyosu::is_not_nan ) | [is_not_real](@ref kyosu::is_not_real ) |
| [is_pure](@ref kyosu::is_pure ) | [is_real](@ref kyosu::is_real ) | [is_unitary](@ref kyosu::is_unitary ) | [jpart](@ref kyosu::jpart ) | [kpart](@ref kyosu::kpart ) |
| [ldiv](@ref kyosu::ldiv ) | [lerp](@ref kyosu::lerp ) | [log](@ref kyosu::log ) | [log10](@ref kyosu::log10 ) | [log1p](@ref kyosu::log1p ) |
| [log_abs](@ref kyosu::log_abs ) | [log2](@ref kyosu::log2 ) | [lpnorm](@ref kyosu::lpnorm ) | [manhattan](@ref kyosu::manhattan ) | [minus](@ref kyosu::minus ) |
| [lpart](@ref kyosu::lpart ) | [lipart](@ref kyosu::lipart ) | [ljpart](@ref kyosu::ljpart ) | [lkpart](@ref kyosu::lkpart ) | |
| [nearest](@ref kyosu::nearest ) | [oneminus](@ref kyosu::oneminus ) | [pow](@ref kyosu::pow ) | [pow1p](@ref kyosu::pow1p ) | [pow_abs](@ref kyosu::pow_abs ) |
| [powm1](@ref kyosu::powm1 ) | [proj](@ref kyosu::proj ) | [pure](@ref kyosu::imag ) | [radinpi](@ref kyosu::radinpi )| [real](@ref kyosu::real ) |
| [rec](@ref kyosu::rec ) | [reldist](@ref kyosu::reldist ) | [reverse_horner](@ref kyosu::reverse_horner ) | [right_horner](@ref kyosu::right_horner ) | [right_reverse_horner](@ref kyosu::right_reverse_horner ) |
| [sec](@ref kyosu::sec ) | [secpi](@ref kyosu::secpi ) | [sech](@ref kyosu::sech ) | | |
| [sign](@ref kyosu::sign ) | [sin](@ref kyosu::sin ) | [sinc](@ref kyosu::sinc ) | [sincos](@ref kyosu::sincos ) | [sinpi](@ref kyosu::sinpi ) |
| [sinpicospi](@ref kyosu::sinpicospi ) | [sinh](@ref kyosu::sinh ) | [sinhcosh](@ref kyosu::sinhcosh ) | [slerp](@ref kyosu::slerp ) | [sqr](@ref kyosu::sqr ) |
| [sqr_abs](@ref kyosu::sqr_abs ) | [sqrt](@ref kyosu::sqrt ) | [tan](@ref kyosu::tan ) | [tanpi](@ref kyosu::tanpi ) | [tanh](@ref kyosu::tanh ) |
| [to_polar](@ref kyosu::to_polar ) | [trunc](@ref kyosu::trunc ) | | | |

* callables usable with complex or real only. These are mainly implementation of some classical meromorphic functions.

| | | | | |
|------------------|------------------|--------------------|------------------|---------------|
| [beta](@ref kyosu::beta ) | [deta](@ref kyosu::deta ) | [digamma](@ref kyosu::digamma ) | [erf](@ref kyosu::erf ) | [erfcx](@ref kyosu::erfcx ) |
| [erfi](@ref kyosu::erfi ) | [eta](@ref kyosu::eta ) | [faddeeva](@ref kyosu::faddeeva ) | [lambda](@ref kyosu::lambda ) | [lbeta](@ref kyosu::lbeta ) |
| [log_abs_gamma](@ref kyosu::log_abs_gamma ) | [log_gamma](@ref kyosu::log_gamma ) | [lrising_factorial](@ref kyosu::lrising_factorial ) | [rising_factorial](@ref kyosu::rising_factorial ) | [tgamma](@ref kyosu::tgamma ) |
| [zeta](@ref kyosu::zeta ) | | | | |
| [ldiv](@ref kyosu::ldiv ) | [lambda](@ref kyosu::lambda ) | [lbeta](@ref kyosu::lbeta ) | [lerp](@ref kyosu::lerp ) | [lipart](@ref kyosu::lipart ) |
| [ljpart](@ref kyosu::ljpart ) | [lkpart](@ref kyosu::lkpart ) | [log](@ref kyosu::log ) | [log2](@ref kyosu::log2 ) | [lpart](@ref kyosu::lpart ) |
| [lipart](@ref kyosu::lipart ) | [ljpart](@ref kyosu::ljpart ) | [lkpart](@ref kyosu::lkpart ) | [lpnorm](@ref kyosu::lpnorm ) | [lrising_factorial](@ref kyosu::lrising_factorial ) |
| [manhattan](@ref kyosu::manhattan ) | [minus](@ref kyosu::minus ) | [nearest](@ref kyosu::nearest ) | [oneminus](@ref kyosu::oneminus )| [pow](@ref kyosu::pow ) |
| [pow1p](@ref kyosu::pow1p ) | [pow_abs](@ref kyosu::pow_abs ) | [powm1](@ref kyosu::powm1 ) | [proj](@ref kyosu::proj ) | [pure](@ref kyosu::imag ) |
| [radinpi](@ref kyosu::radinpi ) | [real](@ref kyosu::real ) | [rec](@ref kyosu::rec ) | [reldist](@ref kyosu::reldist )| [reverse_horner](@ref kyosu::reverse_horner ) |
| [right_horner](@ref kyosu::right_horner ) | [right_reverse_horner](@ref kyosu::right_reverse_horner ) | [rising_factorial](@ref kyosu::rising_factorial ) | [sec](@ref kyosu::sec )| [secpi](@ref kyosu::secpi ) |
| [sech](@ref kyosu::sech ) | [sign](@ref kyosu::sign ) | [sin](@ref kyosu::sin ) | [sinc](@ref kyosu::sinc ) | [sincos](@ref kyosu::sincos ) |
| [sinpi](@ref kyosu::sinpi ) | [sinpicospi](@ref kyosu::sinpicospi ) | [sinh](@ref kyosu::sinh ) | [sinhcosh](@ref kyosu::sinhcosh ) | [slerp](@ref kyosu::slerp ) |
| [sqr](@ref kyosu::sqr ) | [sqr_abs](@ref kyosu::sqr_abs ) | [sqrt](@ref kyosu::sqrt ) | [tan](@ref kyosu::tan ) | [tanpi](@ref kyosu::tanpi ) |
| [tanh](@ref kyosu::tanh ) | [to_polar](@ref kyosu::to_polar ) | [tgamma](@ref kyosu::tgamma ) | [trunc](@ref kyosu::trunc ) | [zeta](@ref kyosu::zeta ) |


* callables usable with quaternion complex and real only

Expand Down
34 changes: 34 additions & 0 deletions include/kyosu/details/cayleyify.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright : KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

auto cayley_extend(auto f, auto z, auto... rs)
{
auto p = kyosu::pure(z);
auto az = kyosu::abs(p);
auto c = f(kyosu::complex(kyosu::real(z), az), rs...);
return kyosu::real(c) + kyosu::ipart(c)*kyosu::sign(p);
}

auto cayley_extend_rev(auto f, auto z1, auto z2)
{
auto p = kyosu::pure(z2);
auto az2 = kyosu::abs(p);
auto c = f(z1, kyosu::complex(kyosu::real(z2), az2));
return kyosu::real(c) + kyosu::ipart(c)*kyosu::sign(p);
}

auto cayley_extend2(auto f, auto z, auto... rs)
{
auto p = kyosu::pure(z);
auto az = kyosu::abs(p);
auto [c1, c2] = f(kyosu::complex(kyosu::real(z), az), rs...);
auto s = kyosu::sign(p);
return kumi::tuple{ kyosu::real(c1) + kyosu::ipart(c1)*s
, kyosu::real(c2) + kyosu::ipart(c2)*s};
}
45 changes: 23 additions & 22 deletions include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <kyosu/functions/atan.hpp>
#include <kyosu/functions/atanh.hpp>
#include <kyosu/functions/average.hpp>
#include <kyosu/functions/beta.hpp>
#include <kyosu/functions/ceil.hpp>
#include <kyosu/functions/commutator.hpp>
#include <kyosu/functions/conj.hpp>
Expand All @@ -46,9 +47,22 @@
#include <kyosu/functions/csc.hpp>
#include <kyosu/functions/cscpi.hpp>
#include <kyosu/functions/csch.hpp>
#include <kyosu/functions/cyl_bessel_i0.hpp>
#include <kyosu/functions/cyl_bessel_i1.hpp>
#include <kyosu/functions/cyl_bessel_in.hpp>
#include <kyosu/functions/cyl_bessel_j0.hpp>
#include <kyosu/functions/cyl_bessel_j1.hpp>
#include <kyosu/functions/cyl_bessel_jn.hpp>
#include <kyosu/functions/cyl_bessel_y0.hpp>
#include <kyosu/functions/dec.hpp>
#include <kyosu/functions/deta.hpp>
#include <kyosu/functions/digamma.hpp>
#include <kyosu/functions/dist.hpp>
#include <kyosu/functions/dot.hpp>
#include <kyosu/functions/erf.hpp>
#include <kyosu/functions/erfcx.hpp>
#include <kyosu/functions/erfi.hpp>
#include <kyosu/functions/eta.hpp>
#include <kyosu/functions/exp.hpp>
#include <kyosu/functions/exp10.hpp>
#include <kyosu/functions/exp2.hpp>
Expand All @@ -57,6 +71,7 @@
#include <kyosu/functions/expm1.hpp>
#include <kyosu/functions/expmx2.hpp>
#include <kyosu/functions/expx2.hpp>
#include <kyosu/functions/faddeeva.hpp>
#include <kyosu/functions/fam.hpp>
#include <kyosu/functions/floor.hpp>
#include <kyosu/functions/fma.hpp>
Expand Down Expand Up @@ -90,18 +105,24 @@
#include <kyosu/functions/is_unitary.hpp>
#include <kyosu/functions/jpart.hpp>
#include <kyosu/functions/kpart.hpp>
#include <kyosu/functions/lambda.hpp>
#include <kyosu/functions/lbeta.hpp>
#include <kyosu/functions/ldiv.hpp>
#include <kyosu/functions/lerp.hpp>
#include <kyosu/functions/log.hpp>
#include <kyosu/functions/log10.hpp>
#include <kyosu/functions/log1p.hpp>
#include <kyosu/functions/log_abs.hpp>
#include <kyosu/functions/log_abs_gamma.hpp>
#include <kyosu/functions/log_gamma.hpp>
#include <kyosu/functions/log2.hpp>
#include <kyosu/functions/lpart.hpp>
#include <kyosu/functions/lipart.hpp>
#include <kyosu/functions/ljpart.hpp>
#include <kyosu/functions/lkpart.hpp>
#include <kyosu/functions/lpnorm.hpp>
#include <kyosu/functions/lrising_factorial.hpp>
#include <kyosu/functions/rising_factorial.hpp>
#include <kyosu/functions/manhattan.hpp>
#include <kyosu/functions/maxabs.hpp>
#include <kyosu/functions/maxmag.hpp>
Expand Down Expand Up @@ -143,35 +164,15 @@
#include <kyosu/functions/tan.hpp>
#include <kyosu/functions/tanpi.hpp>
#include <kyosu/functions/tanh.hpp>
#include <kyosu/functions/tgamma.hpp>
#include <kyosu/functions/to_polar.hpp>
#include <kyosu/functions/trunc.hpp>

//======================================================================================================================
//! @brief Functions performing computations over complex or real elements only.
//======================================================================================================================

#include <kyosu/complex/beta.hpp>
#include <kyosu/complex/deta.hpp>
#include <kyosu/complex/digamma.hpp>
#include <kyosu/complex/erf.hpp>
#include <kyosu/complex/erfcx.hpp>
#include <kyosu/complex/erfi.hpp>
#include <kyosu/complex/eta.hpp>
#include <kyosu/complex/faddeeva.hpp>
#include <kyosu/complex/lambda.hpp>
#include <kyosu/complex/lbeta.hpp>
#include <kyosu/complex/log_abs_gamma.hpp>
#include <kyosu/complex/log_gamma.hpp>
#include <kyosu/complex/lrising_factorial.hpp>
#include <kyosu/complex/rising_factorial.hpp>
#include <kyosu/complex/tgamma.hpp>
#include <kyosu/complex/zeta.hpp>
#include <kyosu/functions/zeta.hpp>

//======================================================================================================================
//! @brief Functions performing computations over quaternion complex or real elements only.
//======================================================================================================================


#include <kyosu/functions/align.hpp>
#include <kyosu/functions/from_angle_axis.hpp>
#include <kyosu/functions/from_cylindrical.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ namespace kyosu
//!
//! **Parameters**
//!
//! * `x`,`y` : Values to process. Can be a mix of complex and real floating values and complex values.
//! * `x`,`y` : Values to process. Can be a mix of cayley_dickson and real floating values.
//!
//! **Return value**
//!
//! 1. If x and y are real typed values returns \f$\displaystyle \mathbf{B}(x,y) = \int_0^1 t^{x-1}(1-t)^{y-1}\mbox{d}t\f$
//! 2. if x or y is complex the value \f$\displaystyle \mathbf{B}(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\f$ is returned.
//! 2. \f$\displaystyle \mathbf{B}(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\f$ is returned.
//!
//! @groupheader{Example}
//!
Expand Down
76 changes: 76 additions & 0 deletions include/kyosu/functions/cyl_bessel_i0.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//======================================================================================================================
/*
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_i0: eve::elementwise
{
using callable_tag_type = callable_cyl_bessel_i0;

KYOSU_DEFERS_CALLABLE(cyl_bessel_i0_);

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

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.
//!
//! 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$.
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto cyl_bessel_i0(T z) noexcept;
//! template<eve::floating_ordered_value T> constexpr T cyl_bessel_i0(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z`: Value to process.
//!
//! **Return value**
//!
//! * return the cylindrical \f$J_0(z)\f$.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/cyl_bessel_i0.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_cyl_bessel_i0 cyl_bessel_i0 = {};
}
Loading

0 comments on commit 0d74499

Please sign in to comment.