Changeset f3094a in git for libpolys/polys/monomials/p_polys.cc
- Timestamp:
- Jul 23, 2012, 5:29:18 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '2234726c50d679d6664181a5c72f75a6fd64a787')
- Children:
- 6779bb431ba1eced98b7cb0e1fed5fbfef1f0244
- Parents:
- 98223c2d11013c57837511c1adb1ef9a16193b3d
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-07-23 17:29:18+02:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-07-25 15:25:07+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/monomials/p_polys.cc
r98223c rf3094a 10 10 11 11 12 13 12 #include "config.h" 13 14 #include <ctype.h> 15 16 #include <omalloc/omalloc.h> 17 14 18 #include <misc/auxiliary.h> 15 19 16 #include <ctype.h>17 #include <omalloc/omalloc.h>18 20 #include <misc/options.h> 19 21 #include <misc/intvec.h> … … 4091 4093 } 4092 4094 } 4095 4096 /*************************************************************** 4097 * 4098 * Storage Managament Routines 4099 * 4100 ***************************************************************/ 4101 4102 4103 static inline unsigned long GetBitFields(long e, 4104 unsigned int s, unsigned int n) 4105 { 4106 #define Sy_bit_L(x) (((unsigned long)1L)<<(x)) 4107 unsigned int i = 0; 4108 unsigned long ev = 0L; 4109 assume(n > 0 && s < BIT_SIZEOF_LONG); 4110 do 4111 { 4112 assume(s+i < BIT_SIZEOF_LONG); 4113 if (e > (long) i) ev |= Sy_bit_L(s+i); 4114 else break; 4115 i++; 4116 } 4117 while (i < n); 4118 return ev; 4119 } 4120 4121 // Short Exponent Vectors are used for fast divisibility tests 4122 // ShortExpVectors "squeeze" an exponent vector into one word as follows: 4123 // Let n = BIT_SIZEOF_LONG / pVariables. 4124 // If n == 0 (i.e. pVariables > BIT_SIZE_OF_LONG), let m == the number 4125 // of non-zero exponents. If (m>BIT_SIZEOF_LONG), then sev = ~0, else 4126 // first m bits of sev are set to 1. 4127 // Otherwise (i.e. pVariables <= BIT_SIZE_OF_LONG) 4128 // represented by a bit-field of length n (resp. n+1 for some 4129 // exponents). If the value of an exponent is greater or equal to n, then 4130 // all of its respective n bits are set to 1. If the value of an exponent 4131 // is smaller than n, say m, then only the first m bits of the respective 4132 // n bits are set to 1, the others are set to 0. 4133 // This way, we have: 4134 // exp1 / exp2 ==> (ev1 & ~ev2) == 0, i.e., 4135 // if (ev1 & ~ev2) then exp1 does not divide exp2 4136 unsigned long p_GetShortExpVector(poly p, const ring r) 4137 { 4138 assume(p != NULL); 4139 if (p == NULL) return 0; 4140 unsigned long ev = 0; // short exponent vector 4141 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp 4142 unsigned int m1; // highest bit which is filled with (n+1) 4143 unsigned int i = 0, j=1; 4144 4145 if (n == 0) 4146 { 4147 if (r->N <2*BIT_SIZEOF_LONG) 4148 { 4149 n=1; 4150 m1=0; 4151 } 4152 else 4153 { 4154 for (; j<=(unsigned long) r->N; j++) 4155 { 4156 if (p_GetExp(p,j,r) > 0) i++; 4157 if (i == BIT_SIZEOF_LONG) break; 4158 } 4159 if (i>0) 4160 ev = ~((unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i)); 4161 return ev; 4162 } 4163 } 4164 else 4165 { 4166 m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N); 4167 } 4168 4169 n++; 4170 while (i<m1) 4171 { 4172 ev |= GetBitFields(p_GetExp(p, j,r), i, n); 4173 i += n; 4174 j++; 4175 } 4176 4177 n--; 4178 while (i<BIT_SIZEOF_LONG) 4179 { 4180 ev |= GetBitFields(p_GetExp(p, j,r), i, n); 4181 i += n; 4182 j++; 4183 } 4184 return ev; 4185 } 4186 4093 4187 /*************************************************************** 4094 4188 *
Note: See TracChangeset
for help on using the changeset viewer.