Changeset 75424e in git for libpolys


Ignore:
Timestamp:
May 30, 2014, 4:28:26 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
7152fa73f01fce2a5964817eb2444114fc5888e4
Parents:
05c60b24c590ed8dce06d86378489249390eca5e121ad4a2fe86746537b889b9ac969034ed1c0dd1
Message:
Merge pull request #592 from adipopescu/64Singular

64 Bits
Location:
libpolys
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    r05c60b2 r75424e  
    1717
    1818// 64 bit version:
    19 //#if SIZEOF_LONG == 8
    20 #if 0
     19#if SIZEOF_LONG == 8
     20//#if 0
    2121#define MAX_NUM_SIZE 60
    2222#define POW_2_28 (1L<<60)
     
    265265  if ( SR_HDL(n) & SR_INT )
    266266  {
    267     term = SR_TO_INT(n);
     267    int nn=SR_TO_INT(n);
     268    if ((long)nn==SR_TO_INT(n))
     269       term = nn;
     270    else
     271    {
     272        mpz_t dummy;
     273        mpz_init_set_si(dummy, SR_TO_INT(n));
     274        term = make_cf(dummy);   
     275    }
    268276  }
    269277  else
     
    534542  nlTest(i, r);
    535543  nlNormalize(i,r);
    536   if (SR_HDL(i) &SR_INT) return SR_TO_INT(i);
     544  if (SR_HDL(i) & SR_INT)
     545  {
     546    int dummy = SR_TO_INT(i);
     547    if((long)dummy == SR_TO_INT(i))
     548        return SR_TO_INT(i);
     549    else
     550        return 0;
     551  }
    537552  if (i->s==3)
    538553  {
     
    563578  nlTest(i, r);
    564579  nlNormalize(i,r);
    565   if (SR_HDL(i) &SR_INT) return (i);
     580  if (SR_HDL(i) & SR_INT) return (i);
    566581  if (i->s==3)
    567582  {
     
    786801  {
    787802    LONG bb=SR_TO_INT(b);
    788     LONG c=SR_TO_INT(a)%bb;
     803    LONG c=SR_TO_INT(a) % bb;
     804    /*if(c < 0)
     805    {   
     806        if(bb < 0)
     807            c = c - bb;
     808        else
     809            c = c + bb;
     810    }*/
     811    /*if((((SR_TO_INT(a)) / (bb))*bb+c) != SR_TO_INT(a))
     812    {
     813        printf("\nERROR longrat:819\n");
     814        printf("\na = %ld\n",SR_TO_INT(a));
     815        printf("\nb = %ld\n",bb);
     816        printf("\nc = %ld\n",c);
     817    }*/
    789818    return INT_TO_SR(c);
    790819  }
    791820  if (SR_HDL(a) & SR_INT)
    792821  {
    793     /* a is a small and b is a large int: -> a */
    794     return a;
     822    // a is a small and b is a large int: -> a
     823    //  INCORRECT, IT COULD HAPPEN THAT b IS A SMALL NUMBER
     824    number aa;
     825    aa=ALLOC_RNUMBER();
     826    mpz_init(aa->z);
     827    mpz_set_si(aa->z, SR_TO_INT(a));
     828    u=ALLOC_RNUMBER();
     829#if defined(LDEBUG)
     830    u->debug=123456;
     831#endif
     832    u->s = 3;
     833    mpz_init(u->z);
     834    mpz_mod(u->z,aa->z,b->z);
     835    if (mpz_isNeg(u->z))
     836    {
     837        if (mpz_isNeg(b->z))
     838          mpz_sub(u->z,aa->z,b->z);
     839        else
     840          mpz_add(u->z,aa->z,b->z);
     841    }
     842    /*mpz_t dummy;
     843    mpz_init(dummy);
     844    mpz_fdiv_q(dummy, aa->z, b->z);
     845    mpz_mul(dummy, dummy, b->z);
     846    mpz_add(dummy, dummy, u->z);
     847    if(mpz_cmp(dummy,aa->z) != 0)
     848    {
     849        printf("\nERROR longrat:911\n");
     850        printf("\na = ");n_Print(aa,r);
     851        gmp_printf("\ndummy = %Zd",dummy);
     852        mpz_clear(dummy);mpz_init(dummy);mpz_tdiv_q(dummy, a->z, b->z);
     853        gmp_printf("\na div b = %Zd\n u = ", dummy);
     854        n_Print(u,r);
     855    }
     856    mpz_clear(dummy);*/
     857    if (aa!=NULL)
     858    {
     859      mpz_clear(aa->z);
     860    #if defined(LDEBUG)
     861      aa->debug=654324;
     862    #endif
     863      FREE_RNUMBER(aa);
     864    }
     865    u=nlShort3(u);
     866    nlTest(u,r);
     867    return u;
    795868  }
    796869  number bb=NULL;
     
    807880  u->s = 3;
    808881  mpz_mod(u->z,a->z,b->z);
    809   if (bb!=NULL)
    810   {
    811     mpz_clear(bb->z);
    812 #if defined(LDEBUG)
    813     bb->debug=654324;
    814 #endif
    815     FREE_RNUMBER(bb);
    816   }
    817882  if (mpz_isNeg(u->z))
    818883  {
     
    822887      mpz_add(u->z,u->z,b->z);
    823888  }
     889  if (bb!=NULL)
     890  {
     891    mpz_clear(bb->z);
     892#if defined(LDEBUG)
     893    bb->debug=654324;
     894#endif
     895    FREE_RNUMBER(bb);
     896  }
     897  /*mpz_t dummy;
     898  mpz_init(dummy);
     899    mpz_fdiv_q(dummy, a->z, b->z);
     900    mpz_mul(dummy, dummy, b->z);
     901    mpz_add(dummy, dummy, u->z);
     902    if(mpz_cmp(dummy,a->z) != 0)
     903    {
     904        printf("\nERROR longrat:911\n");
     905        printf("\na = ");n_Print(a,r);
     906        gmp_printf("\ndummy = %Zd",dummy);
     907        mpz_clear(dummy);mpz_init(dummy);mpz_tdiv_q(dummy, a->z, b->z);
     908        gmp_printf("\na div b = %Zd\n u = ", dummy);
     909        n_Print(u,r);
     910    }
     911    mpz_clear(dummy);*/
    824912  u=nlShort3(u);
    825913  nlTest(u,r);
     
    20922180  assume( getCoeffType(dst) == ID );
    20932181  assume( getCoeffType(src) == ID );
    2094 
    20952182  if ((SR_HDL(a) & SR_INT)||(a==NULL))
    20962183  {
     
    26932780
    26942781    nlInpGcd(cand, n, cf);
    2695 
    26962782    assume( nlGreaterZero(cand,cf) );
    26972783
  • libpolys/coeffs/mpr_complex.cc

    r05c60b2 r75424e  
    377377      if (SR_HDL(num) & SR_INT)
    378378      {
    379         r= SR_TO_INT(num);
     379        //n_Print(num, src);printf("\n");
     380        int nn = SR_TO_INT(num);
     381        if((long)nn == SR_TO_INT(num))
     382            r = SR_TO_INT(num);
     383        else
     384            r = gmp_float(SR_TO_INT(num));
     385        //int dd = 20;
     386        //gmp_printf("\nr = %.*Ff\n",dd,*r.mpfp());
     387        //getchar();
    380388      }
    381389      else
     
    436444      if (SR_HDL(num) & SR_INT)
    437445      {
    438         r= SR_TO_INT(num);
     446        int nn = SR_TO_INT(num);
     447        if((long)nn == SR_TO_INT(num))
     448            r = SR_TO_INT(num);
     449        else
     450            r = gmp_float(SR_TO_INT(num));
    439451      }
    440452      else
     
    446458        if (SR_HDL(num) & SR_INT)
    447459        {
    448           r= SR_TO_INT(num);
     460          int nn = SR_TO_INT(num);
     461          if((long)nn == SR_TO_INT(num))
     462            r = SR_TO_INT(num);
     463          else
     464            r = gmp_float(SR_TO_INT(num));
    449465        }
    450466        else
  • libpolys/coeffs/numbers.cc

    r121ad4 r75424e  
    413413    assume(n->cfInpNeg!=NULL);
    414414    assume(n->cfCopy!=NULL);
    415     assume(n->cfRePart!=NULL);
    416     assume(n->cfImPart!=NULL);
    417415
    418416    assume(n->cfWriteLong!=NULL);
  • libpolys/coeffs/shortfl.cc

    r05c60b2 r75424e  
    425425#define SR_HDL(A) ((long)(A))
    426426#define IS_INT(A) ((A)->s==3)
    427 #define IS_IMM(A) (SR_HDL(A)&SR_INT)
     427#define IS_IMM(A) (SR_HDL(A) & SR_INT)
    428428#define GET_NOM(A) ((A)->z)
    429429#define GET_DENOM(A) ((A)->n)
  • libpolys/polys/ext_fields/algext.cc

    r121ad4 r75424e  
    9898void     naWriteLong(number &a, const coeffs cf);
    9999void     naWriteShort(number &a, const coeffs cf);
    100 number   naRePart(number a, const coeffs cf);
    101 number   naImPart(number a, const coeffs cf);
    102100number   naGetDenom(number &a, const coeffs cf);
    103101number   naGetNumerator(number &a, const coeffs cf);
     
    248246BOOLEAN naDBTest(number a, const char *f, const int l, const coeffs cf)
    249247{
    250   assume(getCoeffType(cf) == ID);
    251248  if (a == NULL) return TRUE;
    252249  p_Test((poly)a, naRing);
    253   if((((poly)a)!=naMinpoly)
    254   && p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing)
    255   && (p_Totaldegree((poly)a, naRing)> 1)) // allow to output par(1)
    256   {
    257     dReportError("deg >= deg(minpoly) in %s:%d\n",f,l);
    258     return FALSE;
     250  if (getCoeffType(cf)==n_algExt)
     251  {
     252    if((((poly)a)!=naMinpoly)
     253    && p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing)
     254    && (p_Totaldegree((poly)a, naRing)> 1)) // allow to output par(1)
     255    {
     256      dReportError("deg >= deg(minpoly) in %s:%d\n",f,l);
     257      return FALSE;
     258    }
    259259  }
    260260  return TRUE;
     
    348348  if (a != NULL) a = (number)p_Neg((poly)a, naRing);
    349349  return a;
    350 }
    351 
    352 number naImPart(number a, const coeffs cf)
    353 {
    354   naTest(a);
    355   return NULL;
    356350}
    357351
     
    486480  poly aPlusB = p_Add_q(p_Copy((poly)a, naRing),
    487481                        p_Copy((poly)b, naRing), naRing);
    488   definiteReduce(aPlusB, naMinpoly, cf);
     482  //definiteReduce(aPlusB, naMinpoly, cf);
    489483  return (number)aPlusB;
    490484}
     
    497491  if (a == NULL) return (number)minusB;
    498492  poly aMinusB = p_Add_q(p_Copy((poly)a, naRing), minusB, naRing);
    499   definiteReduce(aMinusB, naMinpoly, cf);
     493  //definiteReduce(aMinusB, naMinpoly, cf);
    500494  return (number)aMinusB;
    501495}
     
    724718static BOOLEAN naCoeffIsEqual(const coeffs cf, n_coeffType n, void * param)
    725719{
    726   if (ID != n) return FALSE;
     720  if (n_algExt != n) return FALSE;
    727721  AlgExtInfo *e = (AlgExtInfo *)param;
    728722  /* for extension coefficient fields we expect the underlying
     
    14211415  e->r->ref ++; // increase the ref.counter for the ground poly. ring!
    14221416  const ring R = e->r; // no copy!
    1423   assume( R->qideal == e->r->qideal );
    14241417  cf->extRing  = R;
    14251418
     
    14451438  cf->cfChineseRemainder= naChineseRemainder;
    14461439  cf->cfInt          = naInt;
    1447   cf->cfInpNeg          = naNeg;
     1440  cf->cfInpNeg       = naNeg;
    14481441  cf->cfAdd          = naAdd;
    14491442  cf->cfSub          = naSub;
     
    14671460  cf->cfGetNumerator = naGetNumerator;
    14681461  cf->cfRePart       = naCopy;
    1469   cf->cfImPart       = naImPart;
    14701462  cf->cfCoeffWrite   = naCoeffWrite;
    14711463  cf->cfNormalize    = naNormalize;
     
    15031495template class IAccessor<snumber*>;
    15041496
     1497/* --------------------------------------------------------------------*/
     1498#if 0
     1499void npolyCoeffWrite(const coeffs cf, BOOLEAN details)
     1500{
     1501  assume( cf != NULL );
     1502
     1503  const ring A = cf->extRing;
     1504
     1505  assume( A != NULL );
     1506  Print("// polynomial ring as coefficient ring :\n");
     1507  rWrite(A);
     1508  PrintLn();
     1509}
     1510number npolyMult(number a, number b, const coeffs cf)
     1511{
     1512  naTest(a); naTest(b);
     1513  if ((a == NULL)||(b == NULL)) return NULL;
     1514  poly aTimesB = p_Mult_q(p_Copy((poly)a, naRing),
     1515                          p_Copy((poly)b, naRing), naRing);
     1516  return (number)aTimesB;
     1517}
     1518
     1519number npolyDiv(number a, number b, const coeffs cf)
     1520{
     1521  naTest(a); naTest(b);
     1522  if (b == NULL) WerrorS(nDivBy0);
     1523  if (a == NULL) return NULL;
     1524  poly p=singclap_pdivide((poly)a,(poly)b,naRing);
     1525  return (number)p;
     1526}
     1527
     1528
     1529BOOLEAN npolyInitChar(coeffs cf, void * infoStruct)
     1530{
     1531  assume( infoStruct != NULL );
     1532
     1533  AlgExtInfo *e = (AlgExtInfo *)infoStruct;
     1534  /// first check whether cf->extRing != NULL and delete old ring???
     1535
     1536  assume(e->r                     != NULL);      // extRing;
     1537  assume(e->r->cf                 != NULL);      // extRing->cf;
     1538
     1539  assume( cf != NULL );
     1540
     1541  e->r->ref ++; // increase the ref.counter for the ground poly. ring!
     1542  const ring R = e->r; // no copy!
     1543  cf->extRing  = R;
     1544
     1545  /* propagate characteristic up so that it becomes
     1546     directly accessible in cf: */
     1547  cf->ch = R->cf->ch;
     1548
     1549  cf->cfCoeffString = naCoeffString;
     1550
     1551  cf->cfGreaterZero  = naGreaterZero;
     1552  cf->cfGreater      = naGreater;
     1553  cf->cfEqual        = naEqual;
     1554  cf->cfIsZero       = naIsZero;
     1555  cf->cfIsOne        = naIsOne;
     1556  cf->cfIsMOne       = naIsMOne;
     1557  cf->cfInit         = naInit;
     1558  cf->cfInit_bigint  = naInit_bigint;
     1559  cf->cfFarey        = naFarey;
     1560  cf->cfChineseRemainder= naChineseRemainder;
     1561  cf->cfInt          = naInt;
     1562  cf->cfInpNeg       = naNeg;
     1563  cf->cfAdd          = naAdd;
     1564  cf->cfSub          = naSub;
     1565  cf->cfMult         = npolyMult;
     1566  cf->cfDiv          = npolyDiv;
     1567  cf->cfPower        = naPower;
     1568  cf->cfCopy         = naCopy;
     1569
     1570  cf->cfWriteLong        = naWriteLong;
     1571
     1572  if( rCanShortOut(naRing) )
     1573    cf->cfWriteShort = naWriteShort;
     1574  else
     1575    cf->cfWriteShort = naWriteLong;
     1576
     1577  cf->cfRead         = naRead;
     1578  cf->cfDelete       = naDelete;
     1579  cf->cfSetMap       = naSetMap;
     1580  cf->cfGetDenom     = naGetDenom;
     1581  cf->cfGetNumerator = naGetNumerator;
     1582  cf->cfRePart       = naCopy;
     1583  cf->cfCoeffWrite   = npolyCoeffWrite;
     1584  cf->cfNormalize    = npolyNormalize;
     1585  cf->cfKillChar     = naKillChar;
     1586#ifdef LDEBUG
     1587  cf->cfDBTest       = naDBTest;
     1588#endif
     1589  cf->cfGcd          = naGcd;
     1590  cf->cfLcm          = naLcmContent;
     1591  cf->cfSize         = naSize;
     1592  cf->nCoeffIsEqual  = naCoeffIsEqual;
     1593  cf->cfInvers       = npolyInvers;
     1594  cf->cfIntDiv       = npolyDiv;
     1595  cf->convFactoryNSingN=naConvFactoryNSingN;
     1596  cf->convSingNFactoryN=naConvSingNFactoryN;
     1597  cf->cfParDeg = naParDeg;
     1598
     1599  cf->iNumberOfParameters = rVar(R);
     1600  cf->pParameterNames = (const char**)R->names;
     1601  cf->cfParameter = naParameter;
     1602  cf->has_simple_Inverse=FALSE;
     1603  /* cf->has_simple_Alloc= FALSE; */
     1604
     1605  if( nCoeff_is_Q(R->cf) )
     1606  {
     1607    cf->cfClearContent = naClearContent;
     1608    cf->cfClearDenominators = naClearDenominators;
     1609  }
     1610
     1611  return FALSE;
     1612}
     1613#endif
Note: See TracChangeset for help on using the changeset viewer.