diff --git a/include/xsf/legendre.h b/include/xsf/legendre.h index 23fb9e8f3..f9aa9d642 100644 --- a/include/xsf/legendre.h +++ b/include/xsf/legendre.h @@ -310,7 +310,11 @@ void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, T z, int branch_cut, T template void assoc_legendre_p_pm1(NormPolicy norm, int n, int m, dual z, int branch_cut, dual &res) { if (m == 0) { - res[0] = T(1); + if (real(z[0]) >= 0) { + res[0] = T(1); + } else { + res[0] = T(-1); + } } else { res[0] = T(0); }