Skip to content
Draft
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion include/xsf/sph_bessel.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ std::complex<T> sph_bessel_j(long n, std::complex<T> z) {
return 0;
}

std::complex<T> out = std::sqrt(static_cast<T>(M_PI_2) / z) * cyl_bessel_j(n + 1 / static_cast<T>(2), z);
std::complex<T> out = std::sqrt(static_cast<T>(M_PI_2)) * cyl_bessel_j(n + static_cast<T>(0.5), z) / std::sqrt(z);
Copy link
Copy Markdown
Member

@steppi steppi Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks viable. I suggest putting

inline constexpr double SQRT_PI_2 = 1.2533141373155003;

in a detail namespace in this file, and then replacing the above with

std::complex<T> out = static_cast<T>(detail::SQRT_PI_2) * cyl_bessel_j(n + static_cast<T>(0.5), z) / std::sqrt(z);

using inline constexpr let's us sprinkle constants in whichever headers they are needed without running afoul of the one definition rule.

if (std::imag(z) == 0) {
return std::real(out); // Small imaginary part is spurious
}
Expand Down
Loading