Skip to content

Commit f9251dc

Browse files
committed
Make the starting element in assoc_legendre_p_pm1 depend on the sign of z
1 parent 15ffa02 commit f9251dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/xsf/legendre.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,11 @@ void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, T z, int branch_cut, T
310310
template <typename NormPolicy, typename T, size_t Order>
311311
void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, dual<T, Order> z, int branch_cut, dual<T, Order> &res) {
312312
if (m == 0) {
313-
res[0] = T(1);
313+
if (real(z[0]) >= 0) {
314+
res[0] = T(1);
315+
} else {
316+
res[0] = T(-1);
317+
}
314318
} else {
315319
res[0] = T(0);
316320
}

0 commit comments

Comments
 (0)