Changeset 777f8b in git


Ignore:
Timestamp:
Jan 15, 2015, 2:51:44 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
3176e6e1402d3ad808ee0b00f1589716317afe8f94cd934390f0792e899f3342e32c047ac7a34ec9
Parents:
863333d8d5bf4f26782057079f522aa791eab07b
Message:
chg: n_Int returns long instead of int
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/Order/nforder_elt.cc

    r863333 r777f8b  
    143143}
    144144   /// convertion to int, 0 if impossible
    145 static int EltInt(number &n, const coeffs r)
     145static long EltInt(number &n, const coeffs r)
    146146
    147147{
  • Singular/extra.cc

    r863333 r777f8b  
    712712      {
    713713        WerrorS("field required");
    714         return TRUE;
     714        return TRUE;
    715715      }
    716716      matrix pMat  = (matrix)h->Data();
     
    37113711    else
    37123712  #endif
     3713/*==================== test64 =================*/
     3714  #if 0
     3715    if(strcmp(sys_cmd,"test64")==0)
     3716    {
     3717      long l=8;int i;
     3718      for(i=1;i<62;i++)
     3719      {
     3720        l=l<<1;
     3721        number n=n_Init(l,coeffs_BIGINT);
     3722        Print("%ld= ",l);n_Print(n,coeffs_BIGINT);
     3723        CanonicalForm nn=n_convSingNFactoryN(n,TRUE,coeffs_BIGINT);
     3724        n_Delete(&n,coeffs_BIGINT);
     3725        n=n_convFactoryNSingN(nn,coeffs_BIGINT);
     3726        PrintS(" F:");
     3727        n_Print(n,coeffs_BIGINT);
     3728        PrintLn();
     3729        n_Delete(&n,coeffs_BIGINT);
     3730      }
     3731      Print("SIZEOF_LONG=%d\n",SIZEOF_LONG);
     3732      return FALSE;
     3733    }
     3734    else
     3735   #endif
    37133736/*==================== Error =================*/
    37143737      Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
  • Singular/iparith.cc

    r863333 r777f8b  
    239239
    240240/*=================== simple helpers =================*/
     241static int iin_Int(number &n,coeffs cf)
     242{
     243  long l=n_Int(n,cf);
     244  int i=(int)l;
     245  if ((long)i==l) return l;
     246  return 0;
     247}
    241248poly pHeadProc(poly p)
    242249{
     
    47084715    return TRUE;
    47094716  }
    4710   res->data = (char *)(long)n_Int(pGetCoeff(p),currRing->cf);
     4717  res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
    47114718  return FALSE;
    47124719}
     
    54055412{
    54065413  number n=(number)u->CopyD(); // n_Int may call n_Normalize
    5407   res->data=(char *)(long)n_Int(n,currRing->cf);
     5414  res->data=(char *)(long)iin_Int(n,currRing->cf);
    54085415  n_Delete(&n,currRing->cf);
    54095416  return FALSE;
     
    54125419{
    54135420  number n=(number)u->Data();
    5414   res->data=(char *)(long)n_Int(n,coeffs_BIGINT );
     5421  res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
    54155422  return FALSE;
    54165423}
  • Singular/test.cc

    r863333 r777f8b  
    376376     errorreported = 0; // reset error handling
    377377  else
    378      printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data());
     378     printf("typeof returned type %d, >>%s<<\n",r1.Typ(),(char*)r1.Data());
    379379
    380380  // clean up r1:
  • libpolys/coeffs/coeffs.h

    r863333 r777f8b  
    182182   int     (*cfSize)(number n, const coeffs r);
    183183
    184    /// convertion to int, 0 if impossible
    185    int     (*cfInt)(number &n, const coeffs r);
     184   /// convertion to long, 0 if impossible
     185   long    (*cfInt)(number &n, const coeffs r);
    186186
    187187   /// Converts a non-negative number n into a GMP number, 0 if impossible
     
    544544/// conversion of n to an int; 0 if not possible
    545545/// in Z/pZ: the representing int lying in (-p/2 .. p/2]
    546 static FORCE_INLINE int n_Int(number &n,       const coeffs r)
     546static FORCE_INLINE long n_Int(number &n,       const coeffs r)
    547547{ STATISTIC(n_Int); assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); }
    548548
  • libpolys/coeffs/ffields.cc

    r863333 r777f8b  
    2525number  nfInit        (long i, const coeffs r);
    2626number  nfParameter   (int i, const coeffs r);
    27 int     nfInt         (number &n, const coeffs r);
     27long    nfInt         (number &n, const coeffs r);
    2828number  nfAdd         (number a, number b, const coeffs r);
    2929number  nfSub         (number a, number b, const coeffs r);
     
    245245* number -> int
    246246*/
    247 int nfInt (number &, const coeffs )
    248 {
    249   return 0;
     247long nfInt (number &n, const coeffs )
     248{
     249  return (long)n;
    250250}
    251251
  • libpolys/coeffs/gnumpc.cc

    r863333 r777f8b  
    4141BOOLEAN  ngcIsZero(number za, const coeffs r);
    4242number   ngcInit(long i, const coeffs r);
    43 int      ngcInt(number &n, const coeffs r);
     43long     ngcInt(number &n, const coeffs r);
    4444number   ngcNeg(number za, const coeffs r);
    4545number   ngcInvers(number a, const coeffs r);
     
    108108* convert number to int
    109109*/
    110 int ngcInt(number &i, const coeffs r)
    111 {
    112   assume( getCoeffType(r) == ID );
    113 
    114   return (int)((gmp_complex*)i)->real();
     110long ngcInt(number &i, const coeffs r)
     111{
     112  assume( getCoeffType(r) == ID );
     113
     114  return ((gmp_complex*)i)->real();
    115115}
    116116
  • libpolys/coeffs/gnumpfl.cc

    r863333 r777f8b  
    4141BOOLEAN  ngfIsZero(number za, const coeffs r);
    4242number   ngfInit(long i, const coeffs r);
    43 int      ngfInt(number &n, const coeffs r);
     43long     ngfInt(number &n, const coeffs r);
    4444number   ngfNeg(number za, const coeffs r);
    4545number   ngfInvers(number a, const coeffs r);
     
    8282* convert number to int
    8383*/
    84 int ngfInt(number &i, const coeffs r)
     84long ngfInt(number &i, const coeffs r)
    8585{
    8686  assume( getCoeffType(r) == ID );
     
    8888  double d=(double)*(gmp_float*)i;
    8989  if (d<0.0)
    90     return (int)(d-0.5);
     90    return (long)(d-0.5);
    9191  else
    92     return (int)(d+0.5);
     92    return (long)(d+0.5);
    9393}
    9494
    9595int ngfSize(number n, const coeffs r)
    9696{
    97   int i = ngfInt(n, r);
     97  long i = ngfInt(n, r);
    9898  /* basically return the largest integer in n;
    9999     only if this happens to be zero although n != 0,
  • libpolys/coeffs/longrat.cc

    r863333 r777f8b  
    5454BOOLEAN  nlGreater(number a, number b, const coeffs r);
    5555BOOLEAN  nlIsMOne(number a, const coeffs r);
    56 int      nlInt(number &n, const coeffs r);
     56long     nlInt(number &n, const coeffs r);
    5757number   nlBigInt(number &n);
    5858
     
    9595
    9696// 64 bit version:
    97 #if SIZEOF_LONG == 8
    98 //#if 0
     97//#if SIZEOF_LONG == 8
     98#if 0
    9999#define MAX_NUM_SIZE 60
    100100#define POW_2_28 (1L<<60)
     
    193193  assume( getCoeffType(src) == n_Zp );
    194194
    195   number to = nlInit(npInt(from,src), dst); // FIXME? TODO? // extern int     npInt         (number &n, const coeffs r);
     195  number to = nlInit(npInt(from,src), dst); // FIXME? TODO? // extern long     npInt         (number &n, const coeffs r);
    196196
    197197  return to;
     
    609609* convert number to int
    610610*/
    611 int nlInt(number &i, const coeffs r)
     611long nlInt(number &i, const coeffs r)
    612612{
    613613  nlTest(i, r);
     
    615615  if (SR_HDL(i) & SR_INT)
    616616  {
    617     int dummy = SR_TO_INT(i);
    618     if((long)dummy == SR_TO_INT(i))
    619         return SR_TO_INT(i);
    620     else
    621         return 0;
     617    return SR_TO_INT(i);
    622618  }
    623619  if (i->s==3)
    624620  {
    625621    if(mpz_size1(i->z)>MP_SMALL) return 0;
    626     int ul=(int)mpz_get_si(i->z);
    627     if (mpz_cmp_si(i->z,(long)ul)!=0) return 0;
     622    long ul=mpz_get_si(i->z);
     623    if (mpz_cmp_si(i->z,ul)!=0) return 0;
    628624    return ul;
    629625  }
    630626  mpz_t tmp;
    631   int ul;
     627  long ul;
    632628  mpz_init(tmp);
    633629  MPZ_DIV(tmp,i->z,i->n);
     
    635631  else
    636632  {
    637     ul=(int)mpz_get_si(tmp);
    638     if (mpz_cmp_si(tmp,(long)ul)!=0) ul=0;
     633    ul=mpz_get_si(tmp);
     634    if (mpz_cmp_si(tmp,ul)!=0) ul=0;
    639635  }
    640636  mpz_clear(tmp);
     
    953949coeffs nlQuot1(number c, const coeffs r)
    954950{
    955   int ch = r->cfInt(c, r);
     951  long ch = r->cfInt(c, r);
    956952  mpz_ptr dummy;
    957953  dummy = (mpz_ptr) omAlloc(sizeof(mpz_t));
  • libpolys/coeffs/modulop.cc

    r863333 r777f8b  
    3131number  npMult        (number a, number b, const coeffs r);
    3232number  npInit        (long i, const coeffs r);
    33 int     npInt         (number &n, const coeffs r);
     33long    npInt         (number &n, const coeffs r);
    3434number  npAdd         (number a, number b,const coeffs r);
    3535number  npSub         (number a, number b,const coeffs r);
     
    143143 * convert a number to an int in (-p/2 .. p/2]
    144144 */
    145 int npInt(number &n, const coeffs r)
     145long npInt(number &n, const coeffs r)
    146146{
    147147  n_Test(n, r);
    148148
    149   if ((long)n > (((long)r->ch) >>1)) return (int)((long)n -((long)r->ch));
    150   else                               return (int)((long)n);
     149  if ((long)n > (((long)r->ch) >>1)) return ((long)n -((long)r->ch));
     150  else                               return ((long)n);
    151151}
    152152
  • libpolys/coeffs/modulop.h

    r863333 r777f8b  
    125125
    126126// The folloing is reused inside gnumpc.cc, gnumpfl.cc and longrat.cc
    127 int     npInt         (number &n, const coeffs r);
     127long    npInt         (number &n, const coeffs r);
    128128
    129129// The following is currently used in OPAE.cc, OPAEQ.cc and OPAEp.cc for setting their SetMap...
  • libpolys/coeffs/rintegers.cc

    r863333 r777f8b  
    3838number  nrzMult        (number a, number b, const coeffs r);
    3939number  nrzInit        (long i, const coeffs r);
    40 int     nrzInt         (number &n, const coeffs r);
     40long    nrzInt         (number &n, const coeffs r);
    4141number  nrzAdd         (number a, number b, const coeffs r);
    4242number  nrzSub         (number a, number b, const coeffs r);
     
    182182 * convert a number to int
    183183 */
    184 int nrzInt(number &n, const coeffs)
    185 {
    186   return (int) mpz_get_si( (mpz_ptr)n);
     184long nrzInt(number &n, const coeffs)
     185{
     186  return mpz_get_si( (mpz_ptr)n);
    187187}
    188188
     
    468468coeffs nrzQuot1(number c, const coeffs r)
    469469{
    470     int ch = r->cfInt(c, r);
     470    long ch = r->cfInt(c, r);
    471471    mpz_ptr dummy;
    472472    dummy = (mpz_ptr) omAlloc(sizeof(mpz_t));
     
    10691069 * convert a number to int
    10701070 */
    1071 int nrzInt(number &n, const coeffs)
     1071long nrzInt(number &n, const coeffs)
    10721072{
    10731073  if (n_Z_IS_SMALL(n)) return SR_TO_INT(n);
    1074   return (int) mpz_get_si( (mpz_ptr)n);
     1074  return mpz_get_si( (mpz_ptr)n);
    10751075}
    10761076#if CF_DEBUG
     
    16921692    if(n_Z_IS_SMALL(c))
    16931693    {
    1694       int ch = r->cfInt(c, r);
     1694      long ch = r->cfInt(c, r);
    16951695      mpz_init_set_ui(dummy, ch);
    16961696    }
  • libpolys/coeffs/rmodulo2m.cc

    r863333 r777f8b  
    3232number  nr2mMult        (number a, number b, const coeffs r);
    3333number  nr2mInit        (long i, const coeffs r);
    34 int     nr2mInt         (number &n, const coeffs r);
     34long    nr2mInt         (number &n, const coeffs r);
    3535number  nr2mAdd         (number a, number b, const coeffs r);
    3636number  nr2mSub         (number a, number b, const coeffs r);
     
    118118{
    119119    coeffs rr;
    120     int ch = r->cfInt(c, r);
     120    long ch = r->cfInt(c, r);
    121121    mpz_t a,b;
    122122    mpz_init_set(a, r->modNumber);
     
    340340 * convert a number to an int in ]-k/2 .. k/2],
    341341 * where k = 2^m; i.e., an int in ]-2^(m-1) .. 2^(m-1)];
    342  * note that the code computes a long which will then
    343  * automatically casted to int
    344342 */
    345 static long nr2mLong(number &n, const coeffs r)
     343long nr2mInt(number &n, const coeffs r)
    346344{
    347345  unsigned long nn = (unsigned long)(unsigned long)n & r->mod2mMask;
     
    351349  else
    352350    return (long)((unsigned long)nn);
    353 }
    354 int nr2mInt(number &n, const coeffs r)
    355 {
    356   return (int)nr2mLong(n,r);
    357351}
    358352
     
    834828void nr2mWrite (number &a, const coeffs r)
    835829{
    836   long i = nr2mLong(a, r);
     830  long i = nr2mInt(a, r);
    837831  StringAppend("%ld", i);
    838832}
  • libpolys/coeffs/rmodulon.cc

    r863333 r777f8b  
    3434number  nrnMult        (number a, number b, const coeffs r);
    3535number  nrnInit        (long i, const coeffs r);
    36 int     nrnInt         (number &n, const coeffs r);
     36long    nrnInt         (number &n, const coeffs r);
    3737number  nrnAdd         (number a, number b, const coeffs r);
    3838number  nrnSub         (number a, number b, const coeffs r);
     
    118118{
    119119    coeffs rr;
    120     int ch = r->cfInt(c, r);
     120    long ch = r->cfInt(c, r);
    121121    mpz_t a,b;
    122122    mpz_init_set(a, r->modNumber);
     
    261261 * convert a number to int
    262262 */
    263 int nrnInt(number &n, const coeffs)
    264 {
    265   return (int)mpz_get_si((mpz_ptr) n);
     263long nrnInt(number &n, const coeffs)
     264{
     265  return mpz_get_si((mpz_ptr) n);
    266266}
    267267
  • libpolys/coeffs/shortfl.cc

    r863333 r777f8b  
    3232number  nrMult        (number a, number b, const coeffs r);
    3333number  nrInit        (long i, const coeffs r);
    34 int     nrInt         (number &n, const coeffs r);
     34long    nrInt         (number &n, const coeffs r);
    3535number  nrAdd         (number a, number b, const coeffs r);
    3636number  nrSub         (number a, number b, const coeffs r);
     
    117117* convert a number to int
    118118*/
    119 int nrInt(number &n, const coeffs r)
    120 {
    121   assume( getCoeffType(r) == ID );
    122 
    123   int i;
     119long nrInt(number &n, const coeffs r)
     120{
     121  assume( getCoeffType(r) == ID );
     122
     123  long i;
    124124  float f = nf(n).F();
    125125  if (((float)(-MAX_INT_VAL-1) <= f) || ((float)MAX_INT_VAL >= f))
    126     i = (int)f;
     126    i = (long)f;
    127127  else
    128128    i = 0;
  • libpolys/polys/ext_fields/algext.cc

    r863333 r777f8b  
    8888BOOLEAN  naIsZero(number a, const coeffs cf);
    8989number   naInit(long i, const coeffs cf);
    90 int      naInt(number &a, const coeffs cf);
     90long     naInt(number &a, const coeffs cf);
    9191number   naNeg(number a, const coeffs cf);
    9292number   naInvers(number a, const coeffs cf);
     
    356356}
    357357
    358 int naInt(number &a, const coeffs cf)
     358long naInt(number &a, const coeffs cf)
    359359{
    360360  naTest(a);
  • libpolys/polys/ext_fields/transext.cc

    r863333 r777f8b  
    104104BOOLEAN  ntIsZero(number a, const coeffs cf);
    105105number   ntInit(long i, const coeffs cf);
    106 int      ntInt(number &a, const coeffs cf);
     106long     ntInt(number &a, const coeffs cf);
    107107number   ntNeg(number a, const coeffs cf);
    108108number   ntInvers(number a, const coeffs cf);
     
    628628}
    629629
    630 int ntInt(number &a, const coeffs cf)
     630long ntInt(number &a, const coeffs cf)
    631631{
    632632  //check_N(a,cf);
  • libpolys/tests/coeffs_test.h

    r863333 r777f8b  
    499499     number q5 = n_Mult(q3, q4, cf);
    500500     TS_ASSERT(n_Test(q5, cf));
    501      Print("21/2 * 30 = %d\n", n_Int(q5, cf));
     501     Print("21/2 * 30 = %ld\n", n_Int(q5, cf));
    502502     TS_ASSERT(n_Test(q5, cf));
    503503     n_Delete(&q1, cf);
Note: See TracChangeset for help on using the changeset viewer.