Changeset cd964c in git


Ignore:
Timestamp:
Feb 22, 2013, 11:24:13 AM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
088e67fc66fb195ab2e00e54b3494d19574a1092
Parents:
e070751c183f5cec7c3ec5339a0b53ff93302566
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-02-22 11:24:13+01:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-02-22 11:56:22+01:00
Message:
add: new function singclap_gcd_and_divide
Location:
libpolys/polys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/clapsing.cc

    re070751 rcd964c  
    9999}
    100100
     101void singclap_gcd_and_divide ( poly& f, poly& g, const ring r)
     102{
     103  poly res=NULL;
     104
     105  if (f!=NULL) p_Cleardenom(f, r);
     106  if (g!=NULL) p_Cleardenom(g, r);
     107  else         return; // g==0 => but do a p_Cleardenom(f)
     108  if (f==NULL) return; // f==0 => but do a p_Cleardenom(g)
     109
     110  Off(SW_RATIONAL);
     111  CanonicalForm F,G,GCD;
     112  if (rField_is_Q(r) || (rField_is_Zp(r)))
     113  {
     114    bool b1=isOn(SW_USE_EZGCD_P);
     115    Off (SW_USE_NTL_GCD_P);
     116    setCharacteristic( rChar(r) );
     117    F=convSingPFactoryP( f,r );
     118    G=convSingPFactoryP( g,r );
     119    GCD=gcd(F,G);
     120    if (!GCD.isOne())
     121    {
     122      p_Delete(&f,r);
     123      p_Delete(&g,r);
     124      f=convFactoryPSingP( F/GCD, r);
     125      g=convFactoryPSingP( G/GCD, r);
     126    }
     127    if (!b1) Off (SW_USE_EZGCD_P);
     128  }
     129  // and over Q(a) / Fp(a)
     130  else if ( rField_is_Extension(r))
     131  {
     132    if ( rField_is_Q_a(r)) setCharacteristic( 0 );
     133    else                   setCharacteristic( rChar(r) );
     134    if (r->cf->extRing->qideal!=NULL)
     135    {
     136      bool b1=isOn(SW_USE_QGCD);
     137      if ( rField_is_Q_a(r) ) On(SW_USE_QGCD);
     138      CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
     139                                           r->cf->extRing);
     140      Variable a=rootOf(mipo);
     141      F=( convSingAPFactoryAP( f,a,r ) );
     142      G=( convSingAPFactoryAP( g,a,r ) );
     143      GCD=gcd(F,G);
     144      if (!GCD.isOne())
     145      {
     146        p_Delete(&f,r);
     147        p_Delete(&g,r);
     148        f= convFactoryAPSingAP( F/GCD,r );
     149        g= convFactoryAPSingAP( G/GCD,r );
     150      }
     151      if (!b1) Off(SW_USE_QGCD);
     152    }
     153    else
     154    {
     155      F=( convSingTrPFactoryP( f,r ) );
     156      G=( convSingTrPFactoryP( g,r ) );
     157      GCD=gcd(F,G);
     158      if (!GCD.isOne())
     159      {
     160        p_Delete(&f,r);
     161        p_Delete(&g,r);
     162        f= convFactoryPSingTrP( F/GCD,r );
     163        g= convFactoryPSingTrP( G/GCD,r );
     164      }
     165    }
     166  }
     167  else
     168    WerrorS( feNotImplemented );
     169  Off(SW_RATIONAL);
     170}
     171
    101172poly singclap_gcd ( poly f, poly g, const ring r)
    102173{
    103174  poly res=NULL;
    104175
    105   if (f!=NULL) p_Cleardenom(f, r);
     176  if (f!=NULL) p_Cleardenom(f, r);             
    106177  if (g!=NULL) p_Cleardenom(g, r);
    107178  else         return f; // g==0 => gcd=f (but do a p_Cleardenom)
  • libpolys/polys/clapsing.h

    re070751 rcd964c  
    2626poly singclap_gcd ( poly f, poly g, const ring r );
    2727
     28/// clears denominators of f and g, divides by gcd(f,g)
     29void singclap_gcd_and_divide ( poly& f, poly& g, const ring r);
    2830
    2931// commented out!
Note: See TracChangeset for help on using the changeset viewer.