Changeset 40094f in git
- Timestamp:
- Jul 2, 2020, 10:22:19 AM (3 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 53acc46a104d727e78284f0fda06b0ac9460dfae
- Parents:
- 45e2d2305421369847cac77695d8c7aedcbfa7e5
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/FLINTconvert.cc
r45e2d2 r40094f 711 711 Free(exp,N*sizeof(ulong)); 712 712 return result; 713 }714 715 // stolen from:716 // https://graphics.stanford.edu/~seander/bithacks.html#IntegerLog717 static inline int SI_LOG2(int v)718 {719 const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};720 const unsigned int S[] = {1, 2, 4, 8, 16};721 722 unsigned int r = 0; // result of log2(v) will go here723 if (v & b[4]) { v >>= S[4]; r |= S[4]; }724 if (v & b[3]) { v >>= S[3]; r |= S[3]; }725 if (v & b[2]) { v >>= S[2]; r |= S[2]; }726 if (v & b[1]) { v >>= S[1]; r |= S[1]; }727 if (v & b[0]) { v >>= S[0]; r |= S[0]; }728 return (int)r;729 713 } 730 714 -
factory/Makefile.am
r45e2d2 r40094f 101 101 # factory header files 102 102 factory_headers = \ 103 si_log2.h \ 103 104 cf_assert.h \ 104 105 canonicalform.h \ -
factory/canonicalform.cc
r45e2d2 r40094f 427 427 case 0: if ( value->inBaseDomain() ) 428 428 return value->degree(); 429 429 break; 430 430 } 431 431 #endif … … 721 721 } 722 722 else 723 723 /*-----------------------------------------------------*/ 724 724 if ((getCharacteristic()==0) 725 725 &&(!hasAlgVar(*this)) … … 1384 1384 long a = imm2int( value ); 1385 1385 ASSERT( a > 0, "arg to ilog2() less or equal zero" ); 1386 int n = -1; 1387 while ( a > 0 ) 1388 { 1389 n++; 1390 a /=2; 1391 } 1392 return n; 1386 return SI_LOG2_LONG(a); 1393 1387 } 1394 1388 else -
factory/canonicalform.h
r45e2d2 r40094f 33 33 #include "factory/templates/ftmpl_factor.h" 34 34 #include "factory/templates/ftmpl_matrix.h" 35 #include "si_log2.h" 35 36 #ifdef HAVE_OMALLOC 36 37 #ifndef XMEMORY_H -
factory/cf_util.cc
r45e2d2 r40094f 39 39 } 40 40 41 int ilog2 (int a)41 int ilog2 (int v) 42 42 { 43 int n = -1; 44 while ( a > 0 ) 45 { 46 n++; 47 a /=2; 48 } 49 return n; 43 const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 44 const unsigned int S[] = {1, 2, 4, 8, 16}; 45 46 unsigned int r = 0; // result of log2(v) will go here 47 if (v & b[4]) { v >>= S[4]; r |= S[4]; } 48 if (v & b[3]) { v >>= S[3]; r |= S[3]; } 49 if (v & b[2]) { v >>= S[2]; r |= S[2]; } 50 if (v & b[1]) { v >>= S[1]; r |= S[1]; } 51 if (v & b[0]) { v >>= S[0]; r |= S[0]; } 52 return (int)r; 50 53 } 51 54 -
factory/factory.template
r45e2d2 r40094f 25 25 #include "factory/factoryconf.h" 26 26 #include <stdint.h> 27 #include "factory/si_log2.h" 27 28 #ifdef HAVE_OMALLOC 28 29 #include "omalloc/omalloc.h" -
libpolys/coeffs/longrat.h
r45e2d2 r40094f 11 11 #include "coeffs/si_gmp.h" 12 12 #include "coeffs/coeffs.h" 13 #include "factory/si_log2.h" 13 14 14 15 number nlGetDenom(number &n, const coeffs r); /*for SAGE,, better: n_GetDenom */ … … 83 84 unsigned long v; 84 85 v = ABS(i); 85 return SI_LOG2 (v) + 1;86 return SI_LOG2_LONG(v) + 1; 86 87 } 87 88 //assume denominator is 0 -
libpolys/misc/auxiliary.h
r45e2d2 r40094f 116 116 } 117 117 #endif 118 119 // stolen from:120 // https://graphics.stanford.edu/~seander/bithacks.html#IntegerLog121 static inline int SI_LOG2(int v)122 {123 const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};124 const unsigned int S[] = {1, 2, 4, 8, 16};125 126 unsigned int r = 0; // result of log2(v) will go here127 if (v & b[4]) { v >>= S[4]; r |= S[4]; }128 if (v & b[3]) { v >>= S[3]; r |= S[3]; }129 if (v & b[2]) { v >>= S[2]; r |= S[2]; }130 if (v & b[1]) { v >>= S[1]; r |= S[1]; }131 if (v & b[0]) { v >>= S[0]; r |= S[0]; }132 return (int)r;133 }134 118 135 119 typedef void* ADDRESS;
Note: See TracChangeset
for help on using the changeset viewer.