Changeset b90a36 in git


Ignore:
Timestamp:
Jul 15, 2014, 5:53:46 PM (9 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
88355ebe9326d86d566d6c175b82b315be5b63ed
Parents:
8b00cafb736eed4e74873c4326a7c6d326b488af
git-author:
Martin Lee <martinlee84@web.de>2014-07-15 17:53:46+02:00
git-committer:
Martin Lee <martinlee84@web.de>2014-07-17 12:07:11+02:00
Message:
fix: messing up variables in newtonDiv
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facMul.cc

    r8b00ca rb90a36  
    230230mulFLINTQTrunc (const CanonicalForm& F, const CanonicalForm& G, int m)
    231231{
    232   if (F.inCoeffDomain() || G.inCoeffDomain())
    233     return mod (F*G, power (Variable (1), m));
     232  if (F.inCoeffDomain() && G.inCoeffDomain())
     233    return F*G;
     234  if (F.inCoeffDomain())
     235    return mod (F*G, power (G.mvar(), m));
     236  if (G.inCoeffDomain())
     237    return mod (F*G, power (F.mvar(), m));
    234238  Variable alpha;
    235239  if (hasFirstAlgVar (F, alpha) || hasFirstAlgVar (G, alpha))
     
    257261}
    258262
    259 CanonicalForm uniReverse (const CanonicalForm& F, int d)
     263CanonicalForm uniReverse (const CanonicalForm& F, int d, const Variable& x)
    260264{
    261265  if (d == 0)
    262266    return F;
    263267  if (F.inCoeffDomain())
    264     return F*power (Variable (1),d);
    265   Variable x= Variable (1);
     268    return F*power (x,d);
    266269  CanonicalForm result= 0;
    267270  CFIterator i= F;
     
    275278
    276279CanonicalForm
    277 newtonInverse (const CanonicalForm& F, const int n)
     280newtonInverse (const CanonicalForm& F, const int n, const Variable& x)
    278281{
    279282  int l= ilog2(n);
    280283
    281   CanonicalForm g= F [0];
    282 
     284  CanonicalForm g;
     285  if (F.inCoeffDomain())
     286    g= F;
     287  else
     288    g= F [0];
     289
     290  if (!F.inCoeffDomain())
     291    ASSERT (F.mvar() == x, "main variable of F and x differ");
    283292  ASSERT (!g.isZero(), "expected a unit");
    284293
    285294  if (!g.isOne())
    286295    g = 1/g;
    287   Variable x= Variable (1);
    288296  CanonicalForm result;
    289297  int exp= 0;
     
    328336              CanonicalForm& R)
    329337{
     338  ASSERT (F.level() == G.level(), "F and G have different level");
    330339  CanonicalForm A= F;
    331340  CanonicalForm B= G;
    332   Variable x= Variable (1);
    333   int degA= degree (A, x);
    334   int degB= degree (B, x);
     341  Variable x= A.mvar();
     342  int degA= degree (A);
     343  int degB= degree (B);
    335344  int m= degA - degB;
    336345
     
    346355  else
    347356  {
    348     R= uniReverse (A, degA);
    349 
    350     CanonicalForm revB= uniReverse (B, degB);
    351     CanonicalForm buf= revB;
    352     revB= newtonInverse (revB, m + 1);
     357    R= uniReverse (A, degA, x);
     358
     359    CanonicalForm revB= uniReverse (B, degB, x);
     360    revB= newtonInverse (revB, m + 1, x);
    353361    Q= mulFLINTQTrunc (R, revB, m + 1);
    354     Q= uniReverse (Q, m);
     362    Q= uniReverse (Q, m, x);
    355363
    356364    R= A - mulNTL (Q, B);
     
    361369newtonDiv (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& Q)
    362370{
     371  ASSERT (F.level() == G.level(), "F and G have different level");
    363372  CanonicalForm A= F;
    364373  CanonicalForm B= G;
    365   Variable x= Variable (1);
    366   int degA= degree (A, x);
    367   int degB= degree (B, x);
     374  Variable x= A.mvar();
     375  int degA= degree (A);
     376  int degB= degree (B);
    368377  int m= degA - degB;
    369378
     
    378387  else
    379388  {
    380     CanonicalForm R= uniReverse (A, degA);
    381 
    382     CanonicalForm revB= uniReverse (B, degB);
    383     revB= newtonInverse (revB, m + 1);
     389    CanonicalForm R= uniReverse (A, degA, x);
     390    CanonicalForm revB= uniReverse (B, degB, x);
     391    revB= newtonInverse (revB, m + 1, x);
    384392    Q= mulFLINTQTrunc (R, revB, m + 1);
    385     Q= uniReverse (Q, m);
     393    Q= uniReverse (Q, m, x);
    386394  }
    387395}
Note: See TracChangeset for help on using the changeset viewer.