Example #1
0
void CanZass(vec_pair_GF2X_long& factors, const GF2X& f, long verbose)
{
   if (IsZero(f))
      Error("CanZass: bad args");

   double t;
   vec_pair_GF2X_long sfd;
   vec_GF2X x;

   
   if (verbose) { cerr << "square-free decomposition..."; t = GetTime(); }
   SquareFreeDecomp(sfd, f);
   if (verbose) cerr << (GetTime()-t) << "\n";

   factors.SetLength(0);

   long i, j;

   for (i = 0; i < sfd.length(); i++) {
      if (verbose) {
         cerr << "factoring multiplicity " << sfd[i].b 
              << ", deg = " << deg(sfd[i].a) << "\n";
      }

      SFCanZass(x, sfd[i].a, verbose);

      for (j = 0; j < x.length(); j++)
         append(factors, cons(x[j], sfd[i].b));
   }
}
Example #2
0
void berlekamp(vec_pair_ZZ_pX_long& factors, const ZZ_pX& f, long verbose)
{
   double t;
   vec_pair_ZZ_pX_long sfd;
   vec_ZZ_pX x;

   if (!IsOne(LeadCoeff(f)))
      Error("berlekamp: bad args");

   
   if (verbose) { cerr << "square-free decomposition..."; t = GetTime(); }
   SquareFreeDecomp(sfd, f);
   if (verbose) cerr << (GetTime()-t) << "\n";

   factors.SetLength(0);

   long i, j;

   for (i = 0; i < sfd.length(); i++) {
      if (verbose) {
         cerr << "factoring multiplicity " << sfd[i].b 
              << ", deg = " << deg(sfd[i].a) << "\n";
      }

      SFBerlekamp(x, sfd[i].a, verbose);

      for (j = 0; j < x.length(); j++)
         append(factors, cons(x[j], sfd[i].b));
   }
}
Example #3
0
static void ZZX_squarefree_decomposition(struct ZZX*** v, long** e, long* n, struct ZZX* x)
{
    vec_pair_ZZX_long factors;
    SquareFreeDecomp(factors, *x);
    *n = factors.length();
    *v = (ZZX**) malloc(sizeof(ZZX*) * (*n));
    *e = (long*) malloc(sizeof(long) * (*n));
    for (long i = 0; i < (*n); i++) {
        (*v)[i] = new ZZX(factors[i].a);
        (*e)[i] = factors[i].b;
    }
}