From f9251dc271aa59ce489359ad27b6abed20be613f Mon Sep 17 00:00:00 2001 From: Marco Berzborn Date: Tue, 18 Nov 2025 17:49:00 +0100 Subject: [PATCH] Make the starting element in assoc_legendre_p_pm1 depend on the sign of z --- include/xsf/legendre.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); }