Changeset fbdfd4 in git


Ignore:
Timestamp:
Sep 9, 2013, 4:37:38 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
b0fc73b7ae26811903b88a25b1f2d65d78541b15
Parents:
574ceea35db8d5683c990e9f7e364c3e2ae515ca
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-09-09 16:37:38+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-09-09 17:07:38+02:00
Message:
fix: enforce integer coeffs in rational functions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/misc_ip.cc

    r574cee rfbdfd4  
    772772/* version strings */
    773773#ifdef HAVE_FLINT
    774 #ifdef __cplusplus
    775774extern "C"
    776775{
    777 #endif
    778776#ifndef __GMP_BITS_PER_MP_LIMB
    779777#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
    780778#endif
    781779#include <flint/flint.h>
    782 #ifdef __cplusplus
    783 }
    784 #endif
     780}
    785781#endif
    786782
     
    900896#endif
    901897              StringAppend("random=%d\n",siRandomStart);
    902    
     898
    903899#define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
    904900              StringAppendS("built-in modules: {");
     
    906902              StringAppendS("}\n");
    907903#undef SI_SHOW_BUILTIN_MODULE
    908      
    909               StringAppend("\tAC_CONFIGURE_ARGS=%s,\n"
    910                            "\tCC=%s,FLAGS:%s,\n"
    911                            "\tCXX=%s,FLAGS:%s,\n"
    912                            "\tDEFS:%s,CPPFLAGS:%s,\n"
    913                            "\tLDFLAGS:%s,LIBS:%s "
     904
     905              StringAppend("AC_CONFIGURE_ARGS=%s,\n"
     906                           "CC=%s,FLAGS:%s,\n"
     907                           "CXX=%s,FLAGS:%s,\n"
     908                           "DEFS:%s,CPPFLAGS:%s,\n"
     909                           "LDFLAGS:%s,LIBS:%s "
    914910#ifdef __GNUC__
    915911              "(ver: " __VERSION__ ")"
  • libpolys/polys/clapconv.cc

    r574cee rfbdfd4  
    380380      p_SetExp( term, i ,exp[i], r);
    381381    //if (rRing_has_Comp(currRing)) p_SetComp(term, 0, currRing); // done by pInit
    382     pGetCoeff(term) = ALLOC0_RNUMBER(); // Q!?
    383     NUM(pGetCoeff(term))=convFactoryPSingP( f, r->cf->extRing );
     382    pGetCoeff(term)=ntInit(convFactoryPSingP( f, r->cf->extRing ), r->cf);
    384383    p_Setm( term,r );
    385384    result = p_Add_q( result, term,r );
  • libpolys/polys/ext_fields/transext.cc

    r574cee rfbdfd4  
    141141void handleNestedFractionsOverQ(fraction f, const coeffs cf);
    142142
     143/* test routine, usualy disabled *
     144 * if want to activate it, activate also the calls to check_N *
     145 *
     146void check_normalized(number t,const coeffs cf, const char *f, int l)
     147{
     148  if (IS0(t)) return;
     149  if(rField_is_Q(ntRing))
     150  {
     151    poly pp=NUM(t);
     152    while(pp!=NULL)
     153    {
     154      if (((SR_HDL(pGetCoeff(pp)) & SR_INT)==0)&&(SR_HDL(pGetCoeff(pp))!=NULL))
     155      {
     156        if (pGetCoeff(pp)->s==0)
     157        {
     158          Print("NUM not normalized in %s:%d\n",f,l);
     159          p_Normalize(pp,ntRing);
     160        }
     161        else if (pGetCoeff(pp)->s==1)
     162          Print("NUM is rational in %s:%d\n",f,l);
     163      }
     164      pIter(pp);
     165    }
     166    pp=DEN(t);
     167    while(pp!=NULL)
     168    {
     169      if (((SR_HDL(pGetCoeff(pp)) & SR_INT)==0)&&(SR_HDL(pGetCoeff(pp))!=NULL))
     170      {
     171        if (pGetCoeff(pp)->s==0)
     172        {
     173          Print("NUM not normalized in %s:%d\n",f,l);
     174          p_Normalize(pp,ntRing);
     175        }
     176        else if (pGetCoeff(pp)->s==1)
     177          Print("DEN is rational in %s:%d\n",f,l);
     178      }
     179      pIter(pp);
     180    }
     181  }
     182}
     183#define check_N(A,B) check_normalized(A,B,__FILE__,__LINE__)
     184*/
     185
    143186#ifdef LDEBUG
    144187BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs cf)
     
    150193  const fraction t = (fraction)a;
    151194
     195  //check_N(a,cf);
    152196  const poly num = NUM(t);
    153197  assume(num != NULL);   /**< t != 0 ==> numerator(t) != 0 */
     
    240284BOOLEAN ntIsZero(number a, const coeffs cf)
    241285{
     286  //check_N(a,cf);
    242287  ntTest(a); // !!!
    243288  return (IS0(a));
     
    246291void ntDelete(number * a, const coeffs cf)
    247292{
     293  //check_N(*a,cf);
    248294  ntTest(*a); // !!!
    249295  fraction f = (fraction)(*a);
     
    257303BOOLEAN ntEqual(number a, number b, const coeffs cf)
    258304{
     305  //check_N(a,cf);
     306  //check_N(b,cf);
    259307  ntTest(a);
    260308  ntTest(b);
     
    301349number ntCopy(number a, const coeffs cf)
    302350{
     351  //check_N(a,cf);
    303352  ntTest(a); // !!!
    304353  if (IS0(a)) return NULL;
     
    317366number ntGetNumerator(number &a, const coeffs cf)
    318367{
     368  //check_N(a,cf);
    319369  ntTest(a);
    320370  if (IS0(a)) return NULL;
     
    370420
    371421  ntTest((number)result);
     422  //check_N((number)result,cf);
    372423  return (number)result;
    373424}
     
    376427number ntGetDenom(number &a, const coeffs cf)
    377428{
     429  //check_N(a,cf);
    378430  ntTest(a);
    379431
     
    382434  COM (result)= 0;
    383435
    384   if (IS0(a)) 
     436  if (IS0(a))
    385437  {
    386438    NUM (result) = p_One(ntRing);
    387439    return (number)result;
    388440  }
    389      
     441
    390442  definiteGcdCancellation(a, cf, FALSE);
    391    
     443
    392444  fraction f = (fraction)a;
    393    
     445
    394446  assume( !IS0(f) );
    395447
    396448  const BOOLEAN denis1 = DENIS1 (f);
    397  
     449
    398450  if( denis1 && (getCoeffType (ntCoeffs) != n_Q) ) // */1 or 0
    399451  {
     
    471523
    472524  ntTest((number)result);
     525  //check_N((number)result,cf);
    473526  return (number)result;
    474527}
     
    476529BOOLEAN ntIsOne(number a, const coeffs cf)
    477530{
     531  //check_N(a,cf);
    478532  ntTest(a); // !!!
    479533  definiteGcdCancellation(a, cf, FALSE);
     
    484538BOOLEAN ntIsMOne(number a, const coeffs cf)
    485539{
     540  //check_N(a,cf);
    486541  ntTest(a);
    487542  definiteGcdCancellation(a, cf, FALSE);
     
    496551number ntNeg(number a, const coeffs cf)
    497552{
     553  //check_N(a,cf);
    498554  ntTest(a);
    499555  if (!IS0(a))
     
    553609
    554610  ntTest((number)result);
     611  //check_N((number)result,cf);
    555612
    556613  return (number)result;
     
    570627      //COM(result) = 0; // done by omAlloc0Bin
    571628      ntTest((number)result);
     629      //check_N((number)result,cf);
    572630      return (number)result;
    573631    }
     
    587645  {
    588646    number g;
    589     // TODO/NOTE: the following should not be necessary (due to
    590     // Hannes!) as NUM (f) should be over Z!!!
    591     // but it is not: normalize it
     647    // the following is necessary because
     648    // NUM (f) should be over Z,
     649    // while p may be over Q
    592650    CPolyCoeffsEnumerator itr(p);
    593651
     
    606664    {
    607665      DEN (f) = p_NSet(g, ntRing);
     666      p_Normalize(DEN(f), ntRing);
    608667      assume( DEN (f) != NULL );
    609668    }
     
    615674  }
    616675
     676  p_Normalize(p, ntRing);
    617677  NUM(f) = p;
    618678  COM(f) = 0;
    619679
     680  //check_N((number)f,cf);
    620681  ntTest((number)f);
    621682  return (number)f;
     
    624685int ntInt(number &a, const coeffs cf)
    625686{
     687  //check_N(a,cf);
    626688  ntTest(a);
    627689  if (IS0(a)) return 0;
     
    651713BOOLEAN ntGreater(number a, number b, const coeffs cf)
    652714{
     715  //check_N(a,cf);
     716  //check_N(b,cf);
    653717  ntTest(a);
    654718  ntTest(b);
     
    702766BOOLEAN ntGreaterZero(number a, const coeffs cf)
    703767{
     768  //check_N(a,cf);
    704769  ntTest(a);
    705770  if (IS0(a)) return FALSE;
     
    749814number ntDiff(number a, number d, const coeffs cf)
    750815{
     816  //check_N(a,cf);
     817  //check_N(d,cf);
    751818  ntTest(a);
    752819  ntTest(d);
     
    773840
    774841  fraction fa = (fraction)a;
    775   if (DENIS1(fa)) {
    776 
     842  if (DENIS1(fa))
     843  {
    777844     fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    778845     NUM(result) = p_Diff(NUM(fa),k,ntRing);
    779846     DEN(result) = NULL;
    780847     COM(result) = COM(fa);
     848     //check_N((number)result,cf);
    781849     return (number)result;
    782850  }
     
    791859  heuristicGcdCancellation((number)result, cf);
    792860
     861  //check_N((number)result,cf);
    793862  return (number)result;
    794863}
     
    797866number ntAdd(number a, number b, const coeffs cf)
    798867{
     868  //check_N(a,cf);
     869  //check_N(b,cf);
    799870  ntTest(a);
    800871  ntTest(b);
     
    829900//  ntTest((number)result);
    830901
     902  //check_N((number)result,cf);
    831903  return (number)result;
    832904}
     
    834906number ntSub(number a, number b, const coeffs cf)
    835907{
     908  //check_N(a,cf);
     909  //check_N(b,cf);
    836910  ntTest(a);
    837911  ntTest(b);
     
    864938  heuristicGcdCancellation((number)result, cf);
    865939//  ntTest((number)result);
     940  //check_N((number)result,cf);
    866941  return (number)result;
    867942}
     
    869944number ntMult(number a, number b, const coeffs cf)
    870945{
     946  //check_N(a,cf);
     947  //check_N(b,cf);
    871948  ntTest(a); // !!!?
    872949  ntTest(b); // !!!?
     
    889966
    890967
     968  //check_N((number)result,cf);
    891969  if (db == NULL)
    892970  {
     
    905983      COM(result) = COM(fa) + MULT_COMPLEXITY;
    906984      heuristicGcdCancellation((number)result, cf);
    907     }
    908   } else
     985      //check_N((number)result,cf);
     986    }
     987  }
     988  else
    909989  { // b = ?? / ??
    910990    if (da == NULL)
     
    914994      COM(result) = COM(fb) + MULT_COMPLEXITY;
    915995      heuristicGcdCancellation((number)result, cf);
     996      //check_N((number)result,cf);
    916997    }
    917998    else /* both den's are != 1 */
     
    9211002      COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY;
    9221003      heuristicGcdCancellation((number)result, cf);
     1004      //check_N((number)result,cf);
    9231005    }
    9241006  }
     
    9261008//  ntTest((number)result);
    9271009
     1010  //check_N((number)result,cf);
    9281011  return (number)result;
    9291012}
     
    9311014number ntDiv(number a, number b, const coeffs cf)
    9321015{
     1016  //check_N(a,cf);
     1017  //check_N(b,cf);
    9331018  ntTest(a);
    9341019  ntTest(b);
     
    9621047  heuristicGcdCancellation((number)result, cf);
    9631048//  ntTest((number)result);
     1049  //check_N((number)result,cf);
    9641050  return (number)result;
    9651051}
     
    10361122  *b = pow;
    10371123  ntTest(*b);
     1124  //check_N(*b,cf);
    10381125}
    10391126
     
    10691156
    10701157  { /* step (1); see documentation of this procedure above */
    1071     p_Normalize(NUM(f), ntRing);
    1072     p_Normalize(DEN(f), ntRing);
    10731158    number lcmOfDenominators = n_Init(1, ntCoeffs);
    10741159    number c; number tmp;
     
    11631248
    11641249  fraction f = (fraction)a;
    1165   if (COM(f)!=0) p_Normalize(NUM(f), ntRing);
     1250  p_Normalize(NUM(f),ntRing);
    11661251  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
    11671252
    1168   p_Normalize(DEN(f), ntRing);
    1169 
    11701253  assume( DEN(f) != NULL );
     1254  p_Normalize(DEN(f),ntRing);
    11711255
    11721256  /* check whether NUM(f) = DEN(f), and - if so - replace 'a' by 1 */
     
    12191303
    12201304  if (IS0(a)) return;
    1221   if (NUM(f)!=NULL) p_Normalize(NUM(f), ntRing);
    1222   if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);
    12231305  if (!simpleTestsHaveAlreadyBeenPerformed)
    12241306  {
    1225     //p_Normalize(NUM(f), ntRing);
    1226     //if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);
    12271307    if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
    12281308
     
    16621742number ntInvers(number a, const coeffs cf)
    16631743{
     1744  //check_N(a,cf);
    16641745  ntTest(a);
    16651746  if (IS0(a))
     
    17121793  }
    17131794  ntTest((number)result); // !!!!
     1795  //check_N((number)result,cf);
    17141796  return (number)result;
    17151797}
     
    17341816  else                 DEN(ff)=p_NSet(nn,dst->extRing);
    17351817  n_Test((number)ff,dst);
     1818  //check_N((number)ff,dst);
    17361819  return (number)ff;
    17371820}
     
    17821865  DEN(result) = h;
    17831866  COM(result) = COM(f);
     1867  //check_N((number)result,dst);
    17841868  assume(n_Test((number)result, dst));
    17851869  return (number)result;
     
    17901874  assume( n_Test(a, cf) );
    17911875  if (n_IsZero(a, cf)) return NULL;
    1792 
    1793   fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
    1794   // DEN(f) = NULL; COM(f) = 0;
    1795   NUM(f) = prCopyR((poly)a, cf->extRing, dst->extRing);
    1796   assume(n_Test((number)f, dst));
    1797   return (number)f;
     1876  return ntInit(prCopyR((poly)a, cf->extRing, dst->extRing),dst);
    17981877}
    17991878
     
    18171896  NUM(f) = g; // DEN(f) = NULL; COM(f) = 0;
    18181897  assume(n_Test((number)f, dst));
     1898  //check_N((number)f,dst);
    18191899  return (number)f;
    18201900}
     
    18311911  NUM(f) = p; DEN(f) = NULL; COM(f) = 0;
    18321912  assume(n_Test((number)f, dst));
     1913  //check_N((number)f,dst);
    18331914  return (number)f;
    18341915}
     
    18531934  NUM(f) = p; DEN(f) = NULL; COM(f) = 0;
    18541935  assume(n_Test((number)f, dst));
     1936  //check_N((number)f,dst);
    18551937  return (number)f;
    18561938}
     
    19512033  if (n.isZero()) return NULL;
    19522034  poly p=convFactoryPSingP(n,ntRing);
     2035  p_Normalize(p,ntRing);
    19532036  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    19542037  NUM(result) = p;
  • libpolys/polys/monomials/p_polys.cc

    r574cee rfbdfd4  
    36473647        number n=pGetCoeff(DEN(z));
    36483648        zz=p_Div_nn(zz,n,srcExtRing);
     3649        p_Normalize(zz,srcExtRing);
    36493650      }
    36503651      //else
  • libpolys/reporter/dError.cc

    r574cee rfbdfd4  
    6868#endif
    6969
     70#if 0
    7071#ifdef HAVE_EXECINFO_H
    7172  ret = backtrace( buffer, SIZE ); // execinfo.h
     
    121122  malloc_free (ptr);
    122123#endif
     124#endif
    123125
    124126#undef SIZE
Note: See TracChangeset for help on using the changeset viewer.