Changeset 486864 in git


Ignore:
Timestamp:
Mar 7, 2014, 3:58:07 PM (10 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
dbcaa4dc36f3331ba9316e072d2c4c61347c0957
Parents:
36914e05c0ccbede3cb5e25cf2aec8fb52db5905
git-author:
Martin Lee <martinlee84@web.de>2014-03-07 15:58:07+01:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2014-03-17 18:31:54+01:00
Message:
chg: added evaluation function that keeps poly integral
File:
1 edited

Legend:

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

    r36914e r486864  
    517517  numt= t1;
    518518  return pi;
     519}
     520
     521CanonicalForm
     522evaluate (const CanonicalForm& f, const CanonicalForm& g, const CanonicalForm& h, const CanonicalForm& powH)
     523{
     524  if (f.inCoeffDomain())
     525    return f;
     526  CFIterator i= f;
     527  int lastExp = i.exp();
     528  CanonicalForm result = i.coeff()*powH;
     529  i++;
     530  while (i.hasTerms())
     531  {
     532    int i_exp= i.exp();
     533    if ((lastExp - i_exp) == 1)
     534    {
     535      result *= g;
     536      result /= h;
     537    }
     538    else
     539    {
     540      result *= power (g, lastExp - i_exp);
     541      result /= power (h, lastExp - i_exp);
     542    }
     543    result += i.coeff()*powH;
     544    lastExp = i_exp;
     545    i++;
     546  }
     547  if (lastExp != 0)
     548  {
     549    result *= power (g, lastExp);
     550    result /= power (h, lastExp);
     551  }
     552  return result;
     553}
     554
     555
     556/// evaluate f at g/h at v such that powH*f is integral i.e. powH is assumed to be h^degree(f,v)
     557CanonicalForm
     558evaluate (const CanonicalForm& f, const CanonicalForm& g,
     559          const CanonicalForm& h, const CanonicalForm& powH,
     560          const Variable& v)
     561{
     562  if (f.inCoeffDomain())
     563  {
     564    return f*powH;
     565  }
     566
     567  Variable x = f.mvar();
     568  if ( v > x )
     569    return f*powH;
     570  else  if ( v == x )
     571    return evaluate (f, g, h, powH);
     572
     573  // v is less than main variable of f
     574  CanonicalForm result= 0;
     575  for (CFIterator i= f; i.hasTerms(); i++)
     576    result += evaluate (i.coeff(), g, h, powH, v)*power (x, i.exp());
     577  return result;
    519578}
    520579
Note: See TracChangeset for help on using the changeset viewer.