diff --git a/libsrc/curvered.cc b/libsrc/curvered.cc index 422194a..ae79fd6 100644 --- a/libsrc/curvered.cc +++ b/libsrc/curvered.cc @@ -60,38 +60,37 @@ ostream& operator<<(ostream& os, const Kodaira_code& c) bigint root(const bigint& aa, int e, const bigint & p) // the e'th root of aa, mod p { - bigint i, ans, temp; int found=0; - const bigint& a = mod(aa, p); - for (i = 1; (! found); ++i) - {ans = i; - if (e==2) temp = ans*ans - a; - else temp = ans*ans*ans - a; - found = div(p, temp); } -// bigint ans; -// int found = 0; -// bigint a = aa % p; -// for ( ans = 1; (ans<=p) && (! found); ++ans) -// found = div(p, pow(ans,e) - a); //N.B. pow(0,p) causes problems. - return ans; + bigint a = aa%p, r, b, xe(e); + if (is_zero(a)) return a; + if (e==2) + { + sqrt_mod_p(r, a, p); + return r; + } + for (r = 1; r= 0; //ie true if legendre(d,p)=0,1 + if (is_zero(c)) return 1; + return legendre(b*b - 4*a*c, p) >= 0; //ie true if legendre(d,p)=0,1 } //monic version int rootsexist(const bigint& bb, const bigint& cc, const bigint& p) { - static bigint one; one=1; + static const bigint one(1); return rootsexist(one,bb,cc,p); } @@ -354,8 +353,8 @@ bigint local_Tamagawa_exponent(CurveRed& c, const bigint& p) bigint global_Tamagawa_exponent(const CurveRed& c, int real_too) { - const bigint one = BIGINT(1); - const bigint two = BIGINT(2); + static const bigint one(1); + static const bigint two(2); bigint ans = ((real_too && (c.conncomp==2))? two: one); for( const auto& ri : c.reduct_array) @@ -389,29 +388,25 @@ vector tamagawa_primes(const CurveRed& C, int real_too) int getord_p_discr(const CurveRed& c, const bigint& p) { auto ri = c.reduct_array.find(p); - if(ri==c.reduct_array.end()) return 0; - return (ri->second).ord_p_discr; + return (ri==c.reduct_array.end()? 0 : (ri->second).ord_p_discr); } int getord_p_N(const CurveRed& c, const bigint& p) { auto ri = c.reduct_array.find(p); - if(ri==c.reduct_array.end()) return 0; - return (ri->second).ord_p_N; + return (ri==c.reduct_array.end()? 0 : (ri->second).ord_p_N); } int getord_p_j_denom(const CurveRed& c, const bigint& p) { auto ri = c.reduct_array.find(p); - if(ri==c.reduct_array.end()) return 0; - return (ri->second).ord_p_j_denom; + return (ri==c.reduct_array.end()? 0 : (ri->second).ord_p_j_denom); } int getc_p(const CurveRed& c, const bigint& p) { auto ri = c.reduct_array.find(p); - if(ri==c.reduct_array.end()) return 1; - return (ri->second).c_p; + return (ri==c.reduct_array.end()? : (ri->second).c_p); } vector all_cp(const CurveRed& c) @@ -444,8 +439,7 @@ bigint global_Tamagawa_number(CurveRed& c, int real_too) Kodaira_code getKodaira_code(const CurveRed& c, const bigint& p) { auto ri = c.reduct_array.find(p); - if(ri==c.reduct_array.end()) return Kodaira_code(); - return (ri->second).Kcode; + return (ri==c.reduct_array.end()? Kodaira_code() : (ri->second).Kcode); } void CurveRed::output(ostream& os) const @@ -533,30 +527,20 @@ int kro_3(long x); // kronecker(x,3) void CurveRed::setLocalRootNumber2() { - static const bigint two = BIGINT(2); + static const bigint two(2); auto ri = reduct_array.find(two); if(ri==reduct_array.end()) return; Reduction_type& info = ri->second; int kod = PariKodairaCode(info.Kcode); int n2 = neron(2,kod); -#ifdef DEBUG_ESIGN - cout<<"\nIn LocalRootNumber2(), n2 = "<0 odd { static const int kro_m1_tab[4] = {0,1,0,-1}; -#ifdef DEBUG_ESIGN - if (!((x>0)&&(odd(x)))) - { - cout<<"kro_m1() called with x="<0 odd { static const int kro_p2_tab[8] = {0,1,0,-1,0,-1,0,1}; -#ifdef DEBUG_ESIGN - if (!((x>0)&&(odd(x)))) - { - cout<<"kro_p2() called with x="<0 odd { static const int kro_m2_tab[8] = {0,1,0,1,0,-1,0,-1}; -#ifdef DEBUG_ESIGN - if (!((x>0)&&(odd(x)))) - { - cout<<"kro_m2() called with x="<0)) - { - cout<<"kro_3() called with x="<