Changeset 777f8b in git
- Timestamp:
- Jan 15, 2015, 2:51:44 PM (9 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 3176e6e1402d3ad808ee0b00f1589716317afe8f94cd934390f0792e899f3342e32c047ac7a34ec9
- Parents:
- 863333d8d5bf4f26782057079f522aa791eab07b
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/Order/nforder_elt.cc
r863333 r777f8b 143 143 } 144 144 /// convertion to int, 0 if impossible 145 static intEltInt(number &n, const coeffs r)145 static long EltInt(number &n, const coeffs r) 146 146 147 147 { -
Singular/extra.cc
r863333 r777f8b 712 712 { 713 713 WerrorS("field required"); 714 714 return TRUE; 715 715 } 716 716 matrix pMat = (matrix)h->Data(); … … 3711 3711 else 3712 3712 #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 3713 3736 /*==================== Error =================*/ 3714 3737 Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented ); -
Singular/iparith.cc
r863333 r777f8b 239 239 240 240 /*=================== simple helpers =================*/ 241 static 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 } 241 248 poly pHeadProc(poly p) 242 249 { … … 4708 4715 return TRUE; 4709 4716 } 4710 res->data = (char *)(long) n_Int(pGetCoeff(p),currRing->cf);4717 res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf); 4711 4718 return FALSE; 4712 4719 } … … 5405 5412 { 5406 5413 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); 5408 5415 n_Delete(&n,currRing->cf); 5409 5416 return FALSE; … … 5412 5419 { 5413 5420 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 ); 5415 5422 return FALSE; 5416 5423 } -
Singular/test.cc
r863333 r777f8b 376 376 errorreported = 0; // reset error handling 377 377 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()); 379 379 380 380 // clean up r1: -
libpolys/coeffs/coeffs.h
r863333 r777f8b 182 182 int (*cfSize)(number n, const coeffs r); 183 183 184 /// convertion to int, 0 if impossible185 int(*cfInt)(number &n, const coeffs r);184 /// convertion to long, 0 if impossible 185 long (*cfInt)(number &n, const coeffs r); 186 186 187 187 /// Converts a non-negative number n into a GMP number, 0 if impossible … … 544 544 /// conversion of n to an int; 0 if not possible 545 545 /// in Z/pZ: the representing int lying in (-p/2 .. p/2] 546 static FORCE_INLINE intn_Int(number &n, const coeffs r)546 static FORCE_INLINE long n_Int(number &n, const coeffs r) 547 547 { STATISTIC(n_Int); assume(r != NULL); assume(r->cfInt!=NULL); return r->cfInt(n,r); } 548 548 -
libpolys/coeffs/ffields.cc
r863333 r777f8b 25 25 number nfInit (long i, const coeffs r); 26 26 number nfParameter (int i, const coeffs r); 27 intnfInt (number &n, const coeffs r);27 long nfInt (number &n, const coeffs r); 28 28 number nfAdd (number a, number b, const coeffs r); 29 29 number nfSub (number a, number b, const coeffs r); … … 245 245 * number -> int 246 246 */ 247 int nfInt (number &, const coeffs )248 { 249 return 0;247 long nfInt (number &n, const coeffs ) 248 { 249 return (long)n; 250 250 } 251 251 -
libpolys/coeffs/gnumpc.cc
r863333 r777f8b 41 41 BOOLEAN ngcIsZero(number za, const coeffs r); 42 42 number ngcInit(long i, const coeffs r); 43 intngcInt(number &n, const coeffs r);43 long ngcInt(number &n, const coeffs r); 44 44 number ngcNeg(number za, const coeffs r); 45 45 number ngcInvers(number a, const coeffs r); … … 108 108 * convert number to int 109 109 */ 110 intngcInt(number &i, const coeffs r)111 { 112 assume( getCoeffType(r) == ID ); 113 114 return ( int)((gmp_complex*)i)->real();110 long ngcInt(number &i, const coeffs r) 111 { 112 assume( getCoeffType(r) == ID ); 113 114 return ((gmp_complex*)i)->real(); 115 115 } 116 116 -
libpolys/coeffs/gnumpfl.cc
r863333 r777f8b 41 41 BOOLEAN ngfIsZero(number za, const coeffs r); 42 42 number ngfInit(long i, const coeffs r); 43 intngfInt(number &n, const coeffs r);43 long ngfInt(number &n, const coeffs r); 44 44 number ngfNeg(number za, const coeffs r); 45 45 number ngfInvers(number a, const coeffs r); … … 82 82 * convert number to int 83 83 */ 84 intngfInt(number &i, const coeffs r)84 long ngfInt(number &i, const coeffs r) 85 85 { 86 86 assume( getCoeffType(r) == ID ); … … 88 88 double d=(double)*(gmp_float*)i; 89 89 if (d<0.0) 90 return ( int)(d-0.5);90 return (long)(d-0.5); 91 91 else 92 return ( int)(d+0.5);92 return (long)(d+0.5); 93 93 } 94 94 95 95 int ngfSize(number n, const coeffs r) 96 96 { 97 inti = ngfInt(n, r);97 long i = ngfInt(n, r); 98 98 /* basically return the largest integer in n; 99 99 only if this happens to be zero although n != 0, -
libpolys/coeffs/longrat.cc
r863333 r777f8b 54 54 BOOLEAN nlGreater(number a, number b, const coeffs r); 55 55 BOOLEAN nlIsMOne(number a, const coeffs r); 56 intnlInt(number &n, const coeffs r);56 long nlInt(number &n, const coeffs r); 57 57 number nlBigInt(number &n); 58 58 … … 95 95 96 96 // 64 bit version: 97 #if SIZEOF_LONG == 898 //#if 097 //#if SIZEOF_LONG == 8 98 #if 0 99 99 #define MAX_NUM_SIZE 60 100 100 #define POW_2_28 (1L<<60) … … 193 193 assume( getCoeffType(src) == n_Zp ); 194 194 195 number to = nlInit(npInt(from,src), dst); // FIXME? TODO? // extern intnpInt (number &n, const coeffs r);195 number to = nlInit(npInt(from,src), dst); // FIXME? TODO? // extern long npInt (number &n, const coeffs r); 196 196 197 197 return to; … … 609 609 * convert number to int 610 610 */ 611 intnlInt(number &i, const coeffs r)611 long nlInt(number &i, const coeffs r) 612 612 { 613 613 nlTest(i, r); … … 615 615 if (SR_HDL(i) & SR_INT) 616 616 { 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); 622 618 } 623 619 if (i->s==3) 624 620 { 625 621 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; 628 624 return ul; 629 625 } 630 626 mpz_t tmp; 631 intul;627 long ul; 632 628 mpz_init(tmp); 633 629 MPZ_DIV(tmp,i->z,i->n); … … 635 631 else 636 632 { 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; 639 635 } 640 636 mpz_clear(tmp); … … 953 949 coeffs nlQuot1(number c, const coeffs r) 954 950 { 955 intch = r->cfInt(c, r);951 long ch = r->cfInt(c, r); 956 952 mpz_ptr dummy; 957 953 dummy = (mpz_ptr) omAlloc(sizeof(mpz_t)); -
libpolys/coeffs/modulop.cc
r863333 r777f8b 31 31 number npMult (number a, number b, const coeffs r); 32 32 number npInit (long i, const coeffs r); 33 intnpInt (number &n, const coeffs r);33 long npInt (number &n, const coeffs r); 34 34 number npAdd (number a, number b,const coeffs r); 35 35 number npSub (number a, number b,const coeffs r); … … 143 143 * convert a number to an int in (-p/2 .. p/2] 144 144 */ 145 intnpInt(number &n, const coeffs r)145 long npInt(number &n, const coeffs r) 146 146 { 147 147 n_Test(n, r); 148 148 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); 151 151 } 152 152 -
libpolys/coeffs/modulop.h
r863333 r777f8b 125 125 126 126 // The folloing is reused inside gnumpc.cc, gnumpfl.cc and longrat.cc 127 intnpInt (number &n, const coeffs r);127 long npInt (number &n, const coeffs r); 128 128 129 129 // The following is currently used in OPAE.cc, OPAEQ.cc and OPAEp.cc for setting their SetMap... -
libpolys/coeffs/rintegers.cc
r863333 r777f8b 38 38 number nrzMult (number a, number b, const coeffs r); 39 39 number nrzInit (long i, const coeffs r); 40 intnrzInt (number &n, const coeffs r);40 long nrzInt (number &n, const coeffs r); 41 41 number nrzAdd (number a, number b, const coeffs r); 42 42 number nrzSub (number a, number b, const coeffs r); … … 182 182 * convert a number to int 183 183 */ 184 intnrzInt(number &n, const coeffs)185 { 186 return (int)mpz_get_si( (mpz_ptr)n);184 long nrzInt(number &n, const coeffs) 185 { 186 return mpz_get_si( (mpz_ptr)n); 187 187 } 188 188 … … 468 468 coeffs nrzQuot1(number c, const coeffs r) 469 469 { 470 intch = r->cfInt(c, r);470 long ch = r->cfInt(c, r); 471 471 mpz_ptr dummy; 472 472 dummy = (mpz_ptr) omAlloc(sizeof(mpz_t)); … … 1069 1069 * convert a number to int 1070 1070 */ 1071 intnrzInt(number &n, const coeffs)1071 long nrzInt(number &n, const coeffs) 1072 1072 { 1073 1073 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); 1075 1075 } 1076 1076 #if CF_DEBUG … … 1692 1692 if(n_Z_IS_SMALL(c)) 1693 1693 { 1694 intch = r->cfInt(c, r);1694 long ch = r->cfInt(c, r); 1695 1695 mpz_init_set_ui(dummy, ch); 1696 1696 } -
libpolys/coeffs/rmodulo2m.cc
r863333 r777f8b 32 32 number nr2mMult (number a, number b, const coeffs r); 33 33 number nr2mInit (long i, const coeffs r); 34 intnr2mInt (number &n, const coeffs r);34 long nr2mInt (number &n, const coeffs r); 35 35 number nr2mAdd (number a, number b, const coeffs r); 36 36 number nr2mSub (number a, number b, const coeffs r); … … 118 118 { 119 119 coeffs rr; 120 intch = r->cfInt(c, r);120 long ch = r->cfInt(c, r); 121 121 mpz_t a,b; 122 122 mpz_init_set(a, r->modNumber); … … 340 340 * convert a number to an int in ]-k/2 .. k/2], 341 341 * 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 then343 * automatically casted to int344 342 */ 345 static long nr2mLong(number &n, const coeffs r)343 long nr2mInt(number &n, const coeffs r) 346 344 { 347 345 unsigned long nn = (unsigned long)(unsigned long)n & r->mod2mMask; … … 351 349 else 352 350 return (long)((unsigned long)nn); 353 }354 int nr2mInt(number &n, const coeffs r)355 {356 return (int)nr2mLong(n,r);357 351 } 358 352 … … 834 828 void nr2mWrite (number &a, const coeffs r) 835 829 { 836 long i = nr2m Long(a, r);830 long i = nr2mInt(a, r); 837 831 StringAppend("%ld", i); 838 832 } -
libpolys/coeffs/rmodulon.cc
r863333 r777f8b 34 34 number nrnMult (number a, number b, const coeffs r); 35 35 number nrnInit (long i, const coeffs r); 36 intnrnInt (number &n, const coeffs r);36 long nrnInt (number &n, const coeffs r); 37 37 number nrnAdd (number a, number b, const coeffs r); 38 38 number nrnSub (number a, number b, const coeffs r); … … 118 118 { 119 119 coeffs rr; 120 intch = r->cfInt(c, r);120 long ch = r->cfInt(c, r); 121 121 mpz_t a,b; 122 122 mpz_init_set(a, r->modNumber); … … 261 261 * convert a number to int 262 262 */ 263 intnrnInt(number &n, const coeffs)264 { 265 return (int)mpz_get_si((mpz_ptr) n);263 long nrnInt(number &n, const coeffs) 264 { 265 return mpz_get_si((mpz_ptr) n); 266 266 } 267 267 -
libpolys/coeffs/shortfl.cc
r863333 r777f8b 32 32 number nrMult (number a, number b, const coeffs r); 33 33 number nrInit (long i, const coeffs r); 34 intnrInt (number &n, const coeffs r);34 long nrInt (number &n, const coeffs r); 35 35 number nrAdd (number a, number b, const coeffs r); 36 36 number nrSub (number a, number b, const coeffs r); … … 117 117 * convert a number to int 118 118 */ 119 intnrInt(number &n, const coeffs r)120 { 121 assume( getCoeffType(r) == ID ); 122 123 inti;119 long nrInt(number &n, const coeffs r) 120 { 121 assume( getCoeffType(r) == ID ); 122 123 long i; 124 124 float f = nf(n).F(); 125 125 if (((float)(-MAX_INT_VAL-1) <= f) || ((float)MAX_INT_VAL >= f)) 126 i = ( int)f;126 i = (long)f; 127 127 else 128 128 i = 0; -
libpolys/polys/ext_fields/algext.cc
r863333 r777f8b 88 88 BOOLEAN naIsZero(number a, const coeffs cf); 89 89 number naInit(long i, const coeffs cf); 90 intnaInt(number &a, const coeffs cf);90 long naInt(number &a, const coeffs cf); 91 91 number naNeg(number a, const coeffs cf); 92 92 number naInvers(number a, const coeffs cf); … … 356 356 } 357 357 358 intnaInt(number &a, const coeffs cf)358 long naInt(number &a, const coeffs cf) 359 359 { 360 360 naTest(a); -
libpolys/polys/ext_fields/transext.cc
r863333 r777f8b 104 104 BOOLEAN ntIsZero(number a, const coeffs cf); 105 105 number ntInit(long i, const coeffs cf); 106 intntInt(number &a, const coeffs cf);106 long ntInt(number &a, const coeffs cf); 107 107 number ntNeg(number a, const coeffs cf); 108 108 number ntInvers(number a, const coeffs cf); … … 628 628 } 629 629 630 intntInt(number &a, const coeffs cf)630 long ntInt(number &a, const coeffs cf) 631 631 { 632 632 //check_N(a,cf); -
libpolys/tests/coeffs_test.h
r863333 r777f8b 499 499 number q5 = n_Mult(q3, q4, cf); 500 500 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)); 502 502 TS_ASSERT(n_Test(q5, cf)); 503 503 n_Delete(&q1, cf);
Note: See TracChangeset
for help on using the changeset viewer.