Changeset 40227a in git


Ignore:
Timestamp:
Mar 7, 2014, 2:01:40 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
36914e05c0ccbede3cb5e25cf2aec8fb52db5905
Parents:
e0fbbebbddf89f036945fdc00a1659b1841bc7aa
git-author:
Martin Lee <martinlee84@web.de>2014-03-07 14:01:40+01:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2014-03-17 18:31:54+01:00
Message:
chg: added two new psqr functions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/libfac/charset/alg_factor.cc

    re0fbbeb r40227a  
    375375  }
    376376  while ( 1 );
     377}
     378
     379
     380/// pseudo division of f and g wrt. x s.t. multiplier*f=q*g+r
     381/// but only if the leading coefficient of g is of level lower than coeffLevel
     382void
     383psqr (const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q,
     384      CanonicalForm & r, CanonicalForm& multiplier, const Variable& x,
     385      int coeffLevel)
     386{
     387  ASSERT( x.level() > 0, "type error: polynomial variable expected" );
     388  ASSERT( ! g.isZero(), "math error: division by zero" );
     389
     390  // swap variables such that x's level is larger or equal
     391  // than both f's and g's levels.
     392  Variable X;
     393  if (f.level() > g.level())
     394    X= f.mvar();
     395  else
     396    X= g.mvar();
     397  if (X.level() < x.level())
     398    X= x;
     399  CanonicalForm F= swapvar (f, x, X);
     400  CanonicalForm G= swapvar (g, x, X);
     401
     402  // now, we have to calculate the pseudo remainder of F and G
     403  // w.r.t. X
     404  int fDegree= degree (F, X);
     405  int gDegree= degree (G, X);
     406  if (fDegree < 0 || fDegree < gDegree)
     407  {
     408    q= 0;
     409    r= f;
     410  }
     411  else
     412  {
     413    CanonicalForm LCG= LC (G, X);
     414    if (LCG.level() < coeffLevel)
     415    {
     416      multiplier= power (LCG, fDegree - gDegree + 1);
     417      divrem (multiplier*F, G, q, r);
     418      q= swapvar (q, x, X);
     419      r= swapvar (r, x, X);
     420    }
     421    else
     422    {
     423      q= 0;
     424      r= f;
     425    }
     426  }
     427}
     428
     429/// pseudo division of f and g wrt. x s.t. multiplier*f=q*g+r
     430void
     431psqr (const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q,
     432      CanonicalForm & r, CanonicalForm& multiplier, const Variable& x)
     433{
     434    ASSERT( x.level() > 0, "type error: polynomial variable expected" );
     435    ASSERT( ! g.isZero(), "math error: division by zero" );
     436
     437    // swap variables such that x's level is larger or equal
     438    // than both f's and g's levels.
     439    Variable X;
     440    if (f.level() > g.level())
     441      X= f.mvar();
     442    else
     443      X= g.mvar();
     444    if (X.level() < x.level())
     445      X= x;
     446    CanonicalForm F= swapvar (f, x, X);
     447    CanonicalForm G= swapvar (g, x, X);
     448
     449    // now, we have to calculate the pseudo remainder of F and G
     450    // w.r.t. X
     451    int fDegree= degree (F, X);
     452    int gDegree= degree (G, X);
     453    if (fDegree < 0 || fDegree < gDegree)
     454    {
     455      q= 0;
     456      r= f;
     457    }
     458    else
     459    {
     460      CanonicalForm LCG= LC (G, X);
     461      multiplier= power (LCG, fDegree - gDegree + 1);
     462      divrem (multiplier*F, G, q, r);
     463      q= swapvar (q, x, X);
     464      r= swapvar (r, x, X);
     465    }
    377466}
    378467
Note: See TracChangeset for help on using the changeset viewer.