bridge/class-master/depend/pari/src/basemath/elliptic.c
/* Given J an ideal in HNF coprime to 2 and z algebraic integer,
 * return b algebraic integer such that z + 2b in  J */
Given J an ideal in HNF coprime to 2 and z algebraic integer,
return b algebraic integer such that z + 2b in  J
Given J an ideal in HNF coprime to 2 and z algebraic integer return b algebraic integer such that z + 2b in J
static GEN
approx_mod2(GEN J, GEN z)
{
  GEN b = z;
  long i;
  if (typ(b) == t_INT)
  {
    if (mpodd(b)) b = addii(b, gcoeff(J,1,1));
    return shifti(negi(b),-1);
  }
  for (i = lg(J)-1; i >= 1; i--)
  {
    if (mpodd(gel(b,i))) b = ZC_add(b, gel(J,i));
  }
  return gshift(ZC_neg(b), -1);
}
static GEN approx_mod2 ( GEN J , GEN z ) { GEN b = z ; long i ; if ( typ ( b ) == t_INT ) { if ( mpodd ( b ) ) b = addii ( b , gcoeff ( J , 1 , 1 ) ) ; return shifti ( negi ( b ) , -1 ) ; } for ( i = lg ( J ) - 1 ; i >= 1 ; i -- ) { if ( mpodd ( gel ( b , i ) ) ) b = ZC_add ( b , gel ( J , i ) ) ; } return gshift ( ZC_neg ( b ) , -1 ) ; }
Given J an ideal in HNF coprime to 2 and z algebraic integer,
 return b algebraic integer such that z + 2b in  J
Given J an ideal in HNF coprime to 2 and z algebraic integer return b algebraic integer such that z + 2b in J