示例#1
0
NTL_CLIENT

// given tau in F_q compute the 'trace of Frob_q' for the curve
// y^2=x^3+a4*x+a6 over the residue field F_q(tau).  if D!=0, then
// curve is assumed to be smooth.  otherwise, distinguishes between
// mult've and add've red'n and computes correct trace.  (D=disc)

long trace_tau(zz_pE& tau, ell_surfaceInfoT::affine_model& model)
{
    static zz_pE  a4_tau, a6_tau, b, e;

    // additive reduction
    if (IsZero(eval(model.A, tau)))
	return 0;

    // split multiplicative reduction
    if (IsZero(eval(model.M_sp, tau)))
	return +1;

    // non-split multiplicative reduction
    if (IsZero(eval(model.M_ns, tau)))
	return -1;

    // good red'n
    a4_tau = eval(model.a4, tau);
    a6_tau = eval(model.a6, tau);
    ell_pE::init(a4_tau, a6_tau);

    long   order = ell_pE::order();
    static ZZ  trace;
    trace = zz_pE::cardinality()+1-order;
    assert(trace.WideSinglePrecision());
    return to_long(trace);
}
示例#2
0
static void RowTransform(vec_ZZ& A, vec_ZZ& B, const ZZ& MU1)
// x = x - y*MU
{
   static ZZ T, MU;
   long k;

   long n = A.length();
   long i;

   MU = MU1;

   if (MU == 1) {
      for (i = 1; i <= n; i++)
         sub(A(i), A(i), B(i));

      return;
   }

   if (MU == -1) {
      for (i = 1; i <= n; i++)
         add(A(i), A(i), B(i));

      return;
   }

   if (MU == 0) return;

   if (NumTwos(MU) >= NTL_ZZ_NBITS) 
      k = MakeOdd(MU);
   else
      k = 0;


   if (MU.WideSinglePrecision()) {
      long mu1;
      conv(mu1, MU);

      for (i = 1; i <= n; i++) {
         mul(T, B(i), mu1);
         if (k > 0) LeftShift(T, T, k);
         sub(A(i), A(i), T);
      }
   }
   else {
      for (i = 1; i <= n; i++) {
         mul(T, B(i), MU);
         if (k > 0) LeftShift(T, T, k);
         sub(A(i), A(i), T);
      }
   }
}
示例#3
0
文件: LLL.c 项目: Macaulay2/Singular
static
void reduce(long k, long l,
            mat_ZZ& B, vec_long& P, vec_ZZ& D,
            vec_vec_ZZ& lam, mat_ZZ* U)
{
   static ZZ t1;
   static ZZ r;

   if (P(l) == 0) return;
   add(t1, lam(k)(P(l)), lam(k)(P(l)));
   abs(t1, t1);
   if (t1 <= D[P(l)]) return;

   long j;
   long rr, small_r;

   BalDiv(r, lam(k)(P(l)), D[P(l)]);

   if (r.WideSinglePrecision()) {
      small_r = 1;
      rr = to_long(r);
   }
   else {
      small_r = 0;
   }

   if (small_r) {
      MulSubFrom(B(k), B(l), rr);

      if (U) MulSubFrom((*U)(k), (*U)(l), rr);

      for (j = 1; j <= l-1; j++)
         if (P(j) != 0)
            MulSubFrom(lam(k)(P(j)), lam(l)(P(j)), rr);
      MulSubFrom(lam(k)(P(l)), D[P(l)], rr);
   }
   else {
      MulSubFrom(B(k), B(l), r);

      if (U) MulSubFrom((*U)(k), (*U)(l), r);

      for (j = 1; j <= l-1; j++)
         if (P(j) != 0)
            MulSubFrom(lam(k)(P(j)), lam(l)(P(j)), r);
      MulSubFrom(lam(k)(P(l)), D[P(l)], r);
   }


}