Skip to content
Merged
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
6 changes: 5 additions & 1 deletion include/xsf/legendre.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, T z, int branch_cut, T
template <typename NormPolicy, typename T, size_t Order>
void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, dual<T, Order> z, int branch_cut, dual<T, Order> &res) {
if (m == 0) {
res[0] = T(1);
if (real(z[0]) >= 0) {
res[0] = T(1);
} else {
res[0] = T(-1);
}
Comment on lines 317 to 321
Copy link
Collaborator

@steppi steppi Dec 5, 2025

Choose a reason for hiding this comment

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

Suggested change
if (real(z[0]) >= 0) {
res[0] = T(1);
} else {
res[0] = T(-1);
}
if (real(z[0]) >= 0) {
res[0] = T(1);
} else {
res[0] = T(std::pow(-1, n));
}

The current patch breaks the even n case. You can get things to work again by adding dependence on n.
Also, it looks like the adjustment should also be added to the overload for non-dual types currently on lines 301-308:

xsf/include/xsf/legendre.h

Lines 301 to 308 in 98623fd

template <typename NormPolicy, typename T>
void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, T z, int branch_cut, T &res) {
if (m == 0) {
res = T(1);
} else {
res = T(0);
}
}

} else {
res[0] = T(0);
}
Expand Down
Loading