diff --git a/libsharp/sharp_core_inc.c b/libsharp/sharp_core_inc.c index fedf506..4870f4f 100644 --- a/libsharp/sharp_core_inc.c +++ b/libsharp/sharp_core_inc.c @@ -238,10 +238,18 @@ static void Y(iter_to_ieee_spin) (const Tb cth, int *l_, prescale=vload(gen->fscale[gen->m]); for (int i=0; ipreMinus_p) rec2p.v[i]=vneg(rec2p.v[i]); if (gen->preMinus_m) diff --git a/libsharp/sharp_ylmgen_c.c b/libsharp/sharp_ylmgen_c.c index 46ea180..3614fd8 100644 --- a/libsharp/sharp_ylmgen_c.c +++ b/libsharp/sharp_ylmgen_c.c @@ -98,8 +98,14 @@ void sharp_Ylmgen_init (sharp_Ylmgen_C *gen, int l_max, int m_max, int spin) { int mlo=gen->s, mhi=m; if (mhiprefac[m]=fac[2*mhi]/(fac[mhi+mlo]*fac[mhi-mlo]); - gen->fscale[m]=facscale[2*mhi]-facscale[mhi+mlo]-facscale[mhi-mlo]; + double tfac=fac[2*mhi]/fac[mhi+mlo]; + int tscale=facscale[2*mhi]-facscale[mhi+mlo]; + if (tfac>1.0) { tfac*=sharp_fsmall; ++tscale; } + tfac/=fac[mhi-mlo]; + tscale-=facscale[mhi-mlo]; + if (tfac>1.0) { tfac*=sharp_fsmall; ++tscale; } + gen->prefac[m]=tfac; + gen->fscale[m]=tscale; } DEALLOC(fac); DEALLOC(facscale);