- Timestamp:
- Jul 27, 2017, 3:49:53 PM (7 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 6310b17eabaf8a6adfd0f335e522b7de83ddd648
- Parents:
- 99c34cc0dbf214fef21abb247bd17d346ebe019c
- Location:
- libpolys/coeffs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/modulop.cc
r99c34c rbb865e 29 29 number npInit (long i, const coeffs r); 30 30 long npInt (number &n, const coeffs r); 31 number npAdd (number a, number b,const coeffs r);32 number npSub (number a, number b,const coeffs r);33 31 void npPower (number a, int i, number * result,const coeffs r); 34 32 BOOLEAN npIsZero (number a,const coeffs r); … … 123 121 } 124 122 125 number npAdd (number a, number b, const coeffs r)126 {127 n_Test(a, r);128 n_Test(b, r);129 130 number c = npAddM(a,b, r);131 132 n_Test(c, r);133 134 return c;135 }136 137 number npSub (number a, number b, const coeffs r)138 {139 n_Test(a, r);140 n_Test(b, r);141 142 number c = npSubM(a,b,r);143 144 n_Test(c, r);145 146 return c;147 }148 149 123 BOOLEAN npIsZero (number a, const coeffs r) 150 124 { … … 497 471 498 472 r->cfMult = npMult; 499 r->cfSub = npSub; 500 r->cfAdd = npAdd; 473 r->cfInpMult = npInpMultM; 474 r->cfSub = npSubM; 475 r->cfAdd = npAddM; 476 r->cfInpAdd = npInpAddM; 501 477 r->cfDiv = npDiv; 502 478 r->cfInit = npInit; -
libpolys/coeffs/modulop.h
r99c34c rbb865e 46 46 ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) r->ch)); 47 47 } 48 static inline void npInpMultM(number &a, number b, const coeffs r) 49 { 50 a=(number) 51 ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) r->ch)); 52 } 48 53 #else 49 54 static inline number npMultM(number a, number b, const coeffs r) … … 51 56 long x = (long)r->npLogTable[(long)a]+ r->npLogTable[(long)b]; 52 57 return (number)(long)r->npExpTable[x<r->npPminus1M ? x : x- r->npPminus1M]; 58 } 59 static inline void npInpMultM(number &a, number b, const coeffs r) 60 { 61 long x = (long)r->npLogTable[(long)a]+ r->npLogTable[(long)b]; 62 a=(number)(long)r->npExpTable[x<r->npPminus1M ? x : x- r->npPminus1M]; 53 63 } 54 64 #endif … … 80 90 return (number)(R >= r->ch ? R - r->ch : R); 81 91 } 92 static inline void npInpAddM(number &a, number b, const coeffs r) 93 { 94 unsigned long R = (unsigned long)a + (unsigned long)b; 95 a=(number)(R >= r->ch ? R - r->ch : R); 96 } 82 97 static inline number npSubM(number a, number b, const coeffs r) 83 98 { … … 96 111 #endif 97 112 return (number)res; 113 } 114 static inline void npInpAddM(number &a, number b, const coeffs r) 115 { 116 unsigned long res = (long)((unsigned long)a + (unsigned long)b); 117 res -= r->ch; 118 #if SIZEOF_LONG == 8 119 res += ((long)res >> 63) & r->ch; 120 #else 121 res += ((long)res >> 31) & r->ch; 122 #endif 123 a=(number)res; 98 124 } 99 125 static inline number npSubM(number a, number b, const coeffs r)
Note: See TracChangeset
for help on using the changeset viewer.