Changeset 67ed74 in git


Ignore:
Timestamp:
Feb 28, 2012, 2:28:23 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
ea1d44c092bcf442c510d86be308a9afc29bcd29
Parents:
2b76ff6d905b78af2bf4da9742b9754c2d407a2f
git-author:
Martin Lee <martinlee84@web.de>2012-02-28 14:28:23+01:00
git-committer:
Martin Lee <martinlee84@web.de>2012-04-04 14:42:26+02:00
Message:
chg: use FLINT for multiplication over Q(a)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facMul.cc

    r2b76ff r67ed74  
    862862
    863863CanonicalForm
     864reverseSubstQa (const fmpq_poly_t F, int d1, int d2, const Variable& alpha,
     865                const fmpq_poly_t mipo)
     866{
     867  Variable y= Variable (2);
     868  Variable x= Variable (1);
     869
     870  fmpq_poly_t f;
     871  fmpq_poly_init (f);
     872  fmpq_poly_set (f, F);
     873
     874  fmpq_poly_t buf;
     875  CanonicalForm result= 0, result2;
     876  int i= 0;
     877  int degf= fmpq_poly_degree(f);
     878  int k= 0;
     879  int degfSubK;
     880  int repLength;
     881  fmpq_t coeff;
     882  while (degf >= k)
     883  {
     884    degfSubK= degf - k;
     885    if (degfSubK >= d1)
     886      repLength= d1;
     887    else
     888      repLength= degfSubK + 1;
     889
     890    fmpq_init (coeff);
     891    int j= 0;
     892    int l;
     893    result2= 0;
     894    while (j*d2 < repLength)
     895    {
     896      fmpq_poly_init2 (buf, d2);
     897      for (l= 0; l < d2; l++)
     898      {
     899        fmpq_poly_get_coeff_fmpq (coeff, f, k + j*d2 + l);
     900        fmpq_poly_set_coeff_fmpq (buf, l, coeff);
     901      }
     902      _fmpq_poly_normalise (buf);
     903      fmpq_poly_rem (buf, buf, mipo);
     904      result2 += convertFmpq_poly_t2FacCF (buf, alpha)*power (x, j);
     905      j++;
     906      fmpq_poly_clear (buf);
     907    }
     908    if (repLength - j*d2 != 0 && j*d2 - repLength < d2)
     909    {
     910      j--;
     911      repLength -= j*d2;
     912      fmpq_poly_init2 (buf, repLength);
     913      j++;
     914      for (l= 0; l < repLength; l++)
     915      {
     916        fmpq_poly_get_coeff_fmpq (coeff, f, k + j*d2 + l);
     917        fmpq_poly_set_coeff_fmpq (buf, l, coeff);
     918      }
     919      _fmpq_poly_normalise (buf);
     920      fmpq_poly_rem (buf, buf, mipo);
     921      result2 += convertFmpq_poly_t2FacCF (buf, alpha)*power (x, j);
     922      fmpq_poly_clear (buf);
     923    }
     924    fmpq_clear (coeff);
     925
     926    result += result2*power (y, i);
     927    i++;
     928    k= d1*i;
     929  }
     930
     931  fmpq_poly_clear (f);
     932  return result;
     933}
     934
     935CanonicalForm
    864936reverseSubstReciproFp (const nmod_poly_t F, const nmod_poly_t G, int d, int k)
    865937{
     
    12981370  fmpz_poly_clear (FLINTB);
    12991371  return A/(f*g);
     1372}
     1373
     1374CanonicalForm
     1375mulMod2FLINTQa (const CanonicalForm& F, const CanonicalForm& G,
     1376                const CanonicalForm& M)
     1377{
     1378  Variable a;
     1379  if (!hasFirstAlgVar (F,a) && !hasFirstAlgVar (G, a))
     1380    return mulMod2FLINTQ (F, G, M);
     1381  CanonicalForm A= F;
     1382
     1383  int degFx= degree (F, 1);
     1384  int degFa= degree (F, a);
     1385  int degGx= degree (G, 1);
     1386  int degGa= degree (G, a);
     1387
     1388  int d2= degFa+degGa+1;
     1389  int d1= degFx + 1 + degGx;
     1390  d1 *= d2;
     1391
     1392  fmpq_poly_t FLINTF, FLINTG;
     1393  kronSubQa (FLINTF, F, d1, d2);
     1394  kronSubQa (FLINTG, G, d1, d2);
     1395
     1396  fmpq_poly_mullow (FLINTF, FLINTF, FLINTG, d1*degree (M));
     1397
     1398  fmpq_poly_t mipo;
     1399  convertFacCF2Fmpq_poly_t (mipo, getMipo (a));
     1400  CanonicalForm result= reverseSubstQa (FLINTF, d1, d2, a, mipo);
     1401  fmpq_poly_clear (FLINTF);
     1402  fmpq_poly_clear (FLINTG);
     1403  return result;
    13001404}
    13011405
     
    19212025
    19222026#ifdef HAVE_FLINT
    1923   Variable alpha;
    1924   if (getCharacteristic() == 0 && !hasFirstAlgVar (F, alpha)
    1925       && !hasFirstAlgVar (G, alpha))
    1926     return mulMod2FLINTQ (F, G, M);
     2027  if (getCharacteristic() == 0)
     2028    return mulMod2FLINTQa (F, G, M);
    19272029#endif
    19282030
Note: See TracChangeset for help on using the changeset viewer.