Changeset 601105 in git for libpolys/coeffs
- Timestamp:
- Nov 19, 2013, 6:39:47 PM (10 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 448b6571955b81192b53dc7300bb54a1984142e3
- Parents:
- 9d864add8f262ed66a3af97f514c37d01844334c
- Location:
- libpolys/coeffs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
r9d864a r601105 77 77 78 78 /// Creation data needed for finite fields 79 typedef struct 79 typedef struct 80 80 { 81 81 int GFChar; … … 123 123 // general stuff 124 124 numberfunc cfMult, cfSub ,cfAdd ,cfDiv, cfIntDiv, cfIntMod, cfExactDiv; 125 125 126 126 /// init with an integer 127 127 number (*cfInit)(long i,const coeffs r); … … 129 129 /// init with a GMP integer 130 130 number (*cfInitMPZ)(mpz_t i, const coeffs r); 131 131 132 132 /// how complicated, (0) => 0, or positive 133 133 int (*cfSize)(number n, const coeffs r); 134 134 135 135 /// convertion to int, 0 if impossible 136 136 int (*cfInt)(number &n, const coeffs r); … … 138 138 /// Converts a non-negative number n into a GMP number, 0 if impossible 139 139 void (*cfMPZ)(mpz_t result, number &n, const coeffs r); 140 140 141 141 /// changes argument inline: a:= -a 142 142 /// return -a! (no copy is returned) … … 152 152 /// print a given number (long format) 153 153 void (*cfWriteLong)(number &a, const coeffs r); 154 154 155 155 /// print a given number in a shorter way, if possible 156 156 /// e.g. in K(a): a2 instead of a^2 157 157 void (*cfWriteShort)(number &a, const coeffs r); 158 158 159 159 const char * (*cfRead)(const char * s, number * a, const coeffs r); 160 160 void (*cfNormalize)(number &a, const coeffs r); 161 161 162 162 #ifdef HAVE_RINGS 163 163 int (*cfDivComp)(number a,number b,const coeffs r); … … 167 167 #endif 168 168 169 169 170 170 BOOLEAN (*cfGreater)(number a,number b, const coeffs r), 171 171 /// tests … … 211 211 /// create i^th parameter or NULL if not possible 212 212 number (*cfParameter)(const int i, const coeffs r); 213 213 214 214 /// function pointer behind n_ClearContent 215 215 nCoeffsEnumeratorFunc cfClearContent; … … 230 230 231 231 /// the 0 as constant, NULL by default 232 number nNULL; 232 number nNULL; 233 233 int char_flag; 234 234 int ref; … … 302 302 303 303 // BOOLEAN CanShortOut; //< if the elements can be printed in short format 304 // 304 // // this is set to FALSE if a parameter name has >2 chars 305 305 // BOOLEAN ShortOut; //< if the elements should print in short format 306 306 … … 314 314 unsigned short *m_nfPlus1Table; 315 315 int *m_nfMinPoly; 316 316 317 317 // --------------------------------------------------- 318 318 // for Zp: … … 608 608 #endif 609 609 { 610 assume(r != NULL); 610 assume(r != NULL); 611 611 #ifdef LDEBUG 612 assume(r->cfDBTest != NULL); 612 assume(r->cfDBTest != NULL); 613 613 return r->cfDBTest(n, filename, linenumber, r); 614 614 #else … … 640 640 static inline BOOLEAN nCoeff_is_Domain(const coeffs r) 641 641 { 642 assume(r != NULL); 642 assume(r != NULL); 643 643 #ifdef HAVE_RINGS 644 644 return (getCoeffType(r)==n_Z || ((getCoeffType(r)!=n_Z2m) && (getCoeffType(r)!=n_Zn) && (getCoeffType(r)!=n_Znm))); … … 679 679 680 680 static inline int n_ParDeg(number n, const coeffs r) 681 { 682 assume(r != NULL); assume(r->cfParDeg != NULL); return r->cfParDeg(n,r); 681 { 682 assume(r != NULL); assume(r->cfParDeg != NULL); return r->cfParDeg(n,r); 683 683 } 684 684 … … 697 697 assume((iParameter >= 1) || (iParameter <= n_NumberOfParameters(r))); 698 698 assume(r->cfParameter != NULL); 699 return r->cfParameter(iParameter, r); 700 } 701 699 return r->cfParameter(iParameter, r); 700 } 702 701 703 702 static inline number n_Init_bigint(number i, const coeffs dummy, 704 705 { 706 assume(dummy != NULL && dst != NULL); assume(dst->cfInit_bigint!=NULL); 703 const coeffs dst) 704 { 705 assume(dummy != NULL && dst != NULL); assume(dst->cfInit_bigint!=NULL); 707 706 return dst->cfInit_bigint(i, dummy, dst); 708 707 } … … 710 709 static inline number n_RePart(number i, const coeffs cf) 711 710 { 712 assume(cf != NULL); assume(cf->cfRePart!=NULL); 711 assume(cf != NULL); assume(cf->cfRePart!=NULL); 713 712 return cf->cfRePart(i,cf); 714 713 } 715 714 static inline number n_ImPart(number i, const coeffs cf) 716 715 { 717 assume(cf != NULL); assume(cf->cfImPart!=NULL); 716 assume(cf != NULL); assume(cf->cfImPart!=NULL); 718 717 return cf->cfImPart(i,cf); 719 718 } -
libpolys/coeffs/modulop.cc
r9d864a r601105 35 35 { 36 36 assume( getCoeffType(r) == ID ); 37 37 38 38 #if SIZEOF_LONG == 4 39 39 #define ULONG64 (unsigned long long)(unsigned long) … … 41 41 #define ULONG64 (unsigned long) 42 42 #endif 43 return (number) 43 return (number) 44 44 (unsigned long)((ULONG64 a)*(ULONG64 b) % (ULONG64 r->ch)); 45 45 } … … 56 56 { 57 57 assume( n_Test(k, r) ); 58 58 59 59 int h = (int)((long) k); 60 60 return ((int)h !=0) && (h <= (r->ch>>1)); … … 78 78 number c = npMultM(a,b, r); 79 79 assume( n_Test(c, r) ); 80 return c; 80 return c; 81 81 } 82 82 … … 92 92 assume( n_Test(c, r) ); 93 93 return c; 94 94 95 95 } 96 96 … … 102 102 { 103 103 assume( n_Test(n, r) ); 104 104 105 105 if ((long)n > (((long)r->ch) >>1)) return (int)((long)n -((long)r->ch)); 106 106 else return (int)((long)n); … … 111 111 assume( n_Test(a, r) ); 112 112 assume( n_Test(b, r) ); 113 113 114 114 number c = npAddM(a,b, r); 115 115 116 116 assume( n_Test(c, r) ); 117 117 118 118 return c; 119 119 } … … 123 123 assume( n_Test(a, r) ); 124 124 assume( n_Test(b, r) ); 125 125 126 126 number c = npSubM(a,b,r); 127 127 … … 134 134 { 135 135 assume( n_Test(a, r) ); 136 136 137 137 return 0 == (long)a; 138 138 } … … 141 141 { 142 142 assume( n_Test(a, r) ); 143 143 144 144 return 1 == (long)a; 145 145 } … … 148 148 { 149 149 assume( n_Test(a, r) ); 150 150 151 151 return ((r->npPminus1M == (long)a)&&((long)1!=(long)a)); 152 152 } … … 231 231 return (number)0; 232 232 number d; 233 233 234 234 #ifndef HAVE_DIV_MOD 235 235 if ((long)b==0) … … 238 238 return (number)0; 239 239 } 240 240 241 241 int s = r->npLogTable[(long)a] - r->npLogTable[(long)b]; 242 242 if (s < 0) … … 250 250 assume( n_Test(d, r) ); 251 251 return d; 252 252 253 253 } 254 254 number npInvers (number c, const coeffs r) 255 255 { 256 256 assume( n_Test(c, r) ); 257 257 258 258 if ((long)c==0) 259 259 { … … 262 262 } 263 263 number d = npInversM(c,r); 264 264 265 265 assume( n_Test(d, r) ); 266 266 return d; 267 267 268 268 } 269 269 … … 271 271 { 272 272 assume( n_Test(c, r) ); 273 273 274 274 if ((long)c==0) return c; 275 275 276 #if 0 277 number d = npNegM(c,r); 276 #if 0 277 number d = npNegM(c,r); 278 278 assume( n_Test(d, r) ); 279 279 return d; 280 280 #else 281 c = npNegM(c,r); 281 c = npNegM(c,r); 282 282 assume( n_Test(c, r) ); 283 283 return c; 284 #endif 284 #endif 285 285 } 286 286 … … 298 298 assume( n_Test(a, r) ); 299 299 assume( n_Test(b, r) ); 300 300 301 301 // return (long)a == (long)b; 302 302 303 303 return npEqualM(a,b,r); 304 304 } … … 307 307 { 308 308 assume( n_Test(a, r) ); 309 309 310 310 if ((long)a>(((long)r->ch) >>1)) StringAppend("-%d",(int)(((long)r->ch)-((long)a))); 311 311 else StringAppend("%d",(int)((long)a)); … … 436 436 437 437 assume( c > 0 ); 438 438 439 439 int i, w; 440 440 … … 507 507 r->convFactoryNSingN=npConvFactoryNSingN; 508 508 #endif 509 509 510 510 // the variables: 511 511 r->nNULL = (number)0; … … 539 539 % r->ch); 540 540 r->npLogTable[r->npExpTable[i]] = i; 541 if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/) 541 if /*(i == r->ch - 1 ) ||*/ (/*(*/ r->npExpTable[i] == 1 /*)*/) 542 542 break; 543 543 } … … 757 757 #else 758 758 /// TODO: use "long InvMod(long a, const coeffs R)"?! 759 759 760 760 long s; 761 761 762 long u, u0, u1, u2, q, r; // v0, v1, v2, 762 long u, u0, u1, u2, q, r; // v0, v1, v2, 763 763 764 764 u1=1; // v1=0; -
libpolys/coeffs/modulop.h
r9d864a r601105 11 11 // defines are in struct.h 12 12 // define if a*b is with mod instead of tables 13 //#define HAVE_MULT_MOD 13 //#define HAVE_MULT_MOD 14 14 // define if a/b is with mod instead of tables 15 //#define HAVE_DIV_MOD 15 //#define HAVE_DIV_MOD 16 16 // define if an if should be used 17 17 //#define HAVE_GENERIC_ADD … … 71 71 // double ab; 72 72 // long q, res; 73 // 73 // 74 74 // ab = ((double) ((int)a)) * ((double) ((int)b)); 75 75 // q = (long) (ab/((double) npPrimeM)); // q could be off by (+/-) 1 … … 83 83 static inline number npMultM(number a, number b, const coeffs r) 84 84 { 85 return (number) 85 return (number) 86 86 ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) r->ch)); 87 87 }
Note: See TracChangeset
for help on using the changeset viewer.