Changeset 2a4a23 in git
- Timestamp:
- Apr 20, 2018, 3:03:49 PM (5 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- eb6e1d58eb9834a39221581ba56d2e26f61499cc
- Parents:
- 65c1bd5b526a9447123bf85f32538aff3498501c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/misc_ip.cc
r65c1bd r2a4a23 895 895 StringAppendS("AvoidBranching,"); 896 896 #endif 897 #ifdef HAVE_ MULT_MOD897 #ifdef HAVE_GENERIC_MULT 898 898 StringAppendS("GenericMult,"); 899 899 #else 900 900 StringAppendS("TableMult,"); 901 #endif 902 #ifdef HAVE_INVTABLE 903 StringAppendS("invTable,"); 904 #else 905 StringAppendS("no invTable,"); 901 906 #endif 902 907 StringAppendS("\n\t"); -
libpolys/coeffs/modulop.cc
r65c1bd r2a4a23 207 207 s += (s >> 31) & R->ch; 208 208 #endif 209 return s; 209 210 #endif 210 211 } … … 213 214 { 214 215 n_Test(c, r); 215 #if !defined(HAVE_MULT_MOD) && (!defined(HAVE_DIV_MOD)) 216 #ifndef HAVE_GENERIC_MULT 217 #ifndef HAVE_INVTABLE 216 218 number d = (number)(long)r->npExpTable[r->npPminus1M - r->npLogTable[(long)c]]; 217 #else219 #else 218 220 long inv=(long)r->npInvTable[(long)c]; 219 221 if (inv==0) 220 222 { 221 #ifndef HAVE_MULT_MOD222 223 inv = (long)r->npExpTable[r->npPminus1M - r->npLogTable[(long)c]]; 223 #else 224 r->npInvTable[(long)c]=inv; 225 } 226 number d = (number)inv; 227 #endif 228 #else 229 #ifdef HAVE_INVTABLE 230 long inv=(long)r->npInvTable[(long)c]; 231 if (inv==0) 232 { 224 233 inv=InvMod((long)c,r); 225 #endif226 234 r->npInvTable[(long)c]=inv; 227 235 } 236 #else 237 long inv=InvMod((long)c,r); 238 #endif 228 239 number d = (number)inv; 229 240 #endif … … 245 256 246 257 number d; 247 #ifndef HAVE_ DIV_MOD258 #ifndef HAVE_GENERIC_MULT 248 259 int s = r->npLogTable[(long)a] - r->npLogTable[(long)b]; 260 #ifdef HAVE_GENERIC_ADD 249 261 if (s < 0) 250 262 s += r->npPminus1M; 263 #else 264 #if SIZEOF_LONG == 8 265 s += ((long)s >> 63) & r->npPminus1M; 266 #else 267 s += ((long)s >> 31) & r->npPminus1M; 268 #endif 269 #endif 251 270 d = (number)(long)r->npExpTable[s]; 252 271 #else … … 395 414 void npKillChar(coeffs r) 396 415 { 397 #ifdef HAVE_ DIV_MOD416 #ifdef HAVE_INVTABLE 398 417 if (r->npInvTable!=NULL) 399 omFreeSize( (void *)r->npInvTable, r->ch*sizeof(unsigned short) ); 400 r->npInvTable=NULL; 401 #else 418 { 419 omFreeSize( (void *)r->npInvTable, r->ch*sizeof(unsigned short) ); 420 r->npInvTable=NULL; 421 } 422 #endif 423 #ifndef HAVE_GENERIC_MULT 402 424 if (r->npExpTable!=NULL) 403 425 { … … 548 570 #endif 549 571 { 550 #ifdef HAVE_ DIV_MOD572 #ifdef HAVE_INVTABLE 551 573 r->npInvTable=(unsigned short*)omAlloc0( r->ch*sizeof(unsigned short) ); 552 #elif (!defined(HAVE_MULT_MOD)||(!HAVE_DIV_MOD)) 574 #endif 575 #ifndef HAVE_GENERIC_MULT 553 576 r->npExpTable=(unsigned short *)omAlloc0( r->ch*sizeof(unsigned short) ); 554 577 r->npLogTable=(unsigned short *)omAlloc0( r->ch*sizeof(unsigned short) ); … … 801 824 } 802 825 803 static inline long nvInvMod(long a, const coeffs R)804 {805 #ifdef HAVE_DIV_MOD806 return InvMod(a, R);807 #else808 /// TODO: use "long InvMod(long a, const coeffs R)"?!809 810 long s;811 812 long u, u0, u1, u2, q, r; // v0, v1, v2,813 814 u1=1; // v1=0;815 u2=0; // v2=1;816 u = a;817 818 long v = R->ch;819 820 while (v != 0)821 {822 q = u / v;823 r = u % v;824 u = v;825 v = r;826 u0 = u2;827 // v0 = v2;828 u2 = u1 - q*u2;829 // v2 = v1 - q*v2;830 u1 = u0;831 // v1 = v0;832 }833 834 s = u1;835 //t = v1;836 if (s < 0)837 return s + R->ch;838 else839 return s;840 #endif841 }842 843 826 static inline number nvInversM (number c, const coeffs r) 844 827 { 845 long inv= nvInvMod((long)c,r);828 long inv=InvMod((long)c,r); 846 829 return (number)inv; 847 830 } -
libpolys/coeffs/modulop.h
r65c1bd r2a4a23 9 9 #include "misc/auxiliary.h" 10 10 11 // defines are in struct.h 11 12 12 // define if a*b is with mod instead of tables 13 //#define HAVE_ MULT_MOD14 // define if a/b is with mod instead oftables15 //#define HAVE_ DIV_MOD13 //#define HAVE_GENERIC_MULT 14 // define if 1/b is from tables 15 //#define HAVE_INVTABLE 16 16 // define if an if should be used 17 17 //#define HAVE_GENERIC_ADD 18 19 //#undef HAVE_GENERIC_ADD 20 //#undef HAVE_GENERIC_MULT 21 //#undef HAVE_INVTABLE 22 23 //#define HAVE_GENERIC_ADD 1 24 //#define HAVE_GENERIC_MULT 1 25 //#define HAVE_INVTABLE 1 18 26 19 27 // enable large primes (32749 < p < 2^31-) … … 41 49 // return (number)res; 42 50 // } 43 #ifdef HAVE_ MULT_MOD51 #ifdef HAVE_GENERIC_MULT 44 52 static inline number npMultM(number a, number b, const coeffs r) 45 53 { -
m4/cpu-check.m4
r65c1bd r2a4a23 49 49 50 50 AS_CASE([$host_cpu], 51 dnl the following settings seems to be better on itanium processors 52 [ia64*], [ 53 AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add)], 51 54 dnl the following settings seems to be better on i386 and x86_64 processors 52 [i*86*|x86_64*], [AC_DEFINE(HAVE_MULT_MOD,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)], 53 dnl the following settings seems to be better on itanium processors 54 dnl AC_DEFINE(HAVE_MULT_MOD,1,) 55 [ia64*], [AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add)], 55 dnl AC_DEFINE(HAVE_GENERIC_MULT,1,) 56 [i*86*|x86_64*], [ 57 AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add) 58 AC_DEFINE(HAVE_GENERIC_MULT,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms) 59 ], 56 60 dnl the following settings seems to be better on sparc processors 57 61 [sparc*], [ 58 AC_DEFINE(HAVE_MULT_MOD,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms) 59 AC_DEFINE(HAVE_DIV_MOD,1,division using extend euclidian algorithm otherwise using tables of logartihms) 62 AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add) 60 63 ], 61 64 dnl the following settings seems to be better on ppc processors 62 65 dnl testet on: ppc_Linux, 740/750 PowerMac G3, 512k L2 cache 63 [powerpc*| ppc*], [AC_DEFINE(HAVE_MULT_MOD,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)],66 [powerpc*|yyppc*], [AC_DEFINE(HAVE_GENERIC_MULT,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)], 64 67 [] 65 68 )
Note: See TracChangeset
for help on using the changeset viewer.