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

cleaning + simpler arbo #63

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions include/kyosu/bessel.hpp

This file was deleted.

1 change: 0 additions & 1 deletion include/kyosu/constants/wrapped.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#pragma once

#include <kyosu/details/callable.hpp>
#include <eve/module/math.hpp>

namespace kyosu::_
{
Expand Down
95 changes: 0 additions & 95 deletions include/kyosu/core.hpp

This file was deleted.

44 changes: 22 additions & 22 deletions include/kyosu/details/bessel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
*/
//======================================================================================================================
#pragma once
#include <eve/module/core.hpp>
#include <eve/module/math.hpp>
#include <eve/module/special.hpp>
#include <eve/module/bessel.hpp>
#include <kyosu/details/cayleyify.hpp>
#include <complex>
//!======================================================================================================================
//! Up to now bessel functions are only implemented here for scalar orders
//!
//! Up to now complex bessel functions are only implemented for scalar orders (integral or floating)
//!======================================================================================================================
//!
//! Integral orders
Expand Down Expand Up @@ -85,31 +80,36 @@
//! * the caller must provide output as a std::span of kyosu::complex allocated to receive N values
//! values.
//! * These values will be the same as the result of calling :
//! `for (int i = 0; i < N; ++i) output[i] = bessel_x(n0+sgn*i, z)`
//! `for (int i = 0; i < min(N, ceil(abs(n)+1)); ++i) output[i] = bessel_x(n0+sgn*i, z)`
//! where n0 is the fractionnal part of n and sgn is the sign of n.
//! However, even if N is less than ceil(abs(n)+1) the function will return the order n value at z.
//!
//! * Moreover jy and ik functions can be computed together and two ouput parameters can be used
//!
//!======================================================================================================================
//!
//! @warning although float and double versions for the underlying type are available, it is common
//! to obtain poor precision with float based computations.
//!======================================================================================================================


#include <kyosu/types/impl/detail/bessel_utils.hpp>
#include <kyosu/details/bessel/bessel_utils.hpp>
// These files only contain implementation details and do not contain any function
// belonging to the user interface
//
// bessels of integral order
#include <kyosu/types/impl/bessel/cb_jyn.hpp>
#include <kyosu/types/impl/bessel/sb_jyn.hpp>
#include <kyosu/types/impl/bessel/cb_hn.hpp>
#include <kyosu/types/impl/bessel/sb_hn.hpp>
#include <kyosu/types/impl/bessel/cb_ikn.hpp>
#include <kyosu/types/impl/bessel/sb_ikn.hpp>
#include <kyosu/details/bessel/besseln/cb_jyn.hpp>
#include <kyosu/details/bessel/besseln/sb_jyn.hpp>
#include <kyosu/details/bessel/besseln/cb_hn.hpp>
#include <kyosu/details/bessel/besseln/sb_hn.hpp>
#include <kyosu/details/bessel/besseln/cb_ikn.hpp>
#include <kyosu/details/bessel/besseln/sb_ikn.hpp>
// bessels of floating (real) order
#include <kyosu/types/impl/besselr/cb_jyr.hpp>
#include <kyosu/types/impl/besselr/cb_hr.hpp>
#include <kyosu/types/impl/besselr/cb_ikr.hpp>
#include <kyosu/types/impl/besselr/sb_jyr.hpp>
#include <kyosu/types/impl/besselr/sb_hr.hpp>
#include <kyosu/types/impl/besselr/sb_ikr.hpp>
// // airy functions
#include <kyosu/types/impl/besselr/airy.hpp>
#include <kyosu/details/bessel/besselr/cb_jyr.hpp>
#include <kyosu/details/bessel/besselr/cb_hr.hpp>
#include <kyosu/details/bessel/besselr/cb_ikr.hpp>
#include <kyosu/details/bessel/besselr/sb_jyr.hpp>
#include <kyosu/details/bessel/besselr/sb_hr.hpp>
#include <kyosu/details/bessel/besselr/sb_ikr.hpp>
// airy functions
#include <kyosu/details/bessel/besselr/airy.hpp>
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,9 @@
//======================================================================================================================
#pragma once
#include <type_traits>
#include <vector>
//#include <vector>
namespace kyosu::_
{

//===-------------------------------------------------------------------------------------------
// bound
//===-------------------------------------------------------------------------------------------
template<typename Z>
auto bound(Z const & z) noexcept
{
using u_t = eve::underlying_type_t<Z>;
auto z1 = if_else(kyosu::is_not_finite(z), eve::zero, z);
return int(eve::ceil(eve::maximum(abs(z1)*u_t(1.1)+2)));
}

//===-------------------------------------------------------------------------------------------
// R use lentz
//===-------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -153,51 +141,4 @@ namespace kyosu::_
auto r = lentz_b(re, eve::eps(eve::as<u_t>()));
return r;
}

template<typename Z>
inline auto Rs(size_t n, Z z) noexcept
// compute the ratio Jn(i, z)/Jn(i+1, z)J for i = n-1:-1:0
{
std::vector<Z> rs(n);
using u_t = eve::underlying_type_t<Z>;
if (is_eqz(n)) return rs;
Z r{}, s{};
auto rz = rec(z);
rs[n-1] = R(n, z);
for(int i=n-1; i >= 1; --i)
{
rs[i-1] = 2*i*rz-rec(rs[i]);
}
return rs;
}


template<typename Z>
inline auto Js(size_t n, Z z) noexcept
// compute Jn(i, z) for i = n:-1:0
{
auto rs = Rs(n+1, z);
std::vector<Z> js(n+1);
js[n] = cyl_bessel_jn(n, z);
for(int i=n-1; i >= 0; --i)
{
js[i] = js[i+1]*rs[i];
}
return js;
}



template<typename Z>
inline auto arg_adjust(Z z) noexcept
// modify ipart of z modulo 2*pi fit in ]-pi +pi]
{
if constexpr(kyosu::concepts::complex<Z>)
{
ipart(z) = eve::rem[eve::to_nearest](ipart(z), 2*eve::pi(eve::as(ipart(z))));
return z;
}
else return z;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//======================================================================================================================
#pragma once
#include <type_traits>
#include <eve/module/core.hpp>

namespace kyosu::_
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
*/
//======================================================================================================================
#pragma once
#include <eve/module/math.hpp>
#include <kyosu/types/impl/detail/bessel_utils2.hpp>
#include <kyosu/details/bessel/bessel_utils2.hpp>
#include <kyosu/details/with_alloca.hpp>
#include <kyosu/types/impl/bessel/cb_hn.hpp>
#include <kyosu/details/bessel/besseln/cb_hn.hpp>
namespace kyosu::_
{
/////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
*/
//======================================================================================================================
#pragma once
#include <eve/module/math.hpp>
#include <kyosu/types/impl/detail/bessel_utils2.hpp>
#include <kyosu/details/bessel/bessel_utils2.hpp>
#include <kyosu/details/with_alloca.hpp>
#include <kyosu/core.hpp>
#include <kyosu/math.hpp>


namespace kyosu::_
{
Expand All @@ -32,6 +28,18 @@ namespace kyosu::_
//===-------------------------------------------------------------------------------------------
//===-------------------------------------------------------------------------------------------


//===-------------------------------------------------------------------------------------------
// bound
//===-------------------------------------------------------------------------------------------
template<typename Z>
auto bound(Z const & z) noexcept
{
using u_t = eve::underlying_type_t<Z>;
auto z1 = if_else(kyosu::is_not_finite(z), eve::zero, z);
return int(eve::ceil(eve::maximum(abs(z1)*u_t(1.1)+2)));
}

template<eve::integral_scalar_value N, typename Z>
Z cb_jn(N nn, Z z);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/
//======================================================================================================================
#pragma once
#include <eve/module/math.hpp>
#include <kyosu/math.hpp>

namespace kyosu::_
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/
//======================================================================================================================
#pragma once
#include <eve/module/math.hpp>
#include <kyosu/types/impl/detail/bessel_utils2.hpp>
#include <kyosu/details/bessel/bessel_utils2.hpp>

namespace kyosu::_
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//======================================================================================================================
#pragma once
#include <kyosu/details/with_alloca.hpp>
#include <kyosu/types/impl/besselr/cb_jyr.hpp>
#include <kyosu/details/bessel/besselr/cb_jyr.hpp>
namespace kyosu::_
{
/////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
//======================================================================================================================
#pragma once
#include <kyosu/types/impl/detail/bessel_utils2.hpp>
#include <kyosu/types/impl/bessel/cb_jyn.hpp>
#include <kyosu/types/impl/besselr/cb_jyr01.hpp>
#include <kyosu/details/bessel/bessel_utils2.hpp>
#include <kyosu/details/bessel/besseln/cb_jyn.hpp>
#include <kyosu/details/bessel/besselr/cb_jyr01.hpp>
#include <kyosu/details/with_alloca.hpp>

namespace kyosu::_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
//======================================================================================================================
#pragma once
#include <kyosu/types/impl/detail/bessel_utils2.hpp>
#include <kyosu/types/impl/bessel/cb_jyn.hpp>
#include <kyosu/types/impl/besselr/cb_jyr01.hpp>
#include <kyosu/details/bessel/bessel_utils2.hpp>
#include <kyosu/details/bessel/besseln/cb_jyn.hpp>
#include <kyosu/details/bessel/besselr/cb_jyr01.hpp>
#include <kyosu/details/with_alloca.hpp>
#include <vector>

Expand Down
Loading