Changeset f3094a in git for libpolys/polys/monomials
- Timestamp:
- Jul 23, 2012, 5:29:18 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- 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
- Location:
- libpolys/polys/monomials
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/monomials/monomials.cc
r98223c rf3094a 30 30 #endif 31 31 32 #include <polys/monomials/ring.h>33 #include <reporter/reporter.h>34 #include <coeffs/numbers.h>35 #include <polys/monomials/ring.h>36 #include <polys/monomials/p_polys.h>37 #include <reporter/reporter.h>38 39 #ifdef PDEBUG40 int pDBsyzComp=0;41 #endif42 43 /***************************************************************44 *45 * Storage Managament Routines46 *47 ***************************************************************/48 49 50 static inline unsigned long GetBitFields(long e,51 unsigned int s, unsigned int n)52 {53 #define Sy_bit_L(x) (((unsigned long)1L)<<(x))54 unsigned int i = 0;55 unsigned long ev = 0L;56 assume(n > 0 && s < BIT_SIZEOF_LONG);57 do58 {59 assume(s+i < BIT_SIZEOF_LONG);60 if (e > (long) i) ev |= Sy_bit_L(s+i);61 else break;62 i++;63 }64 while (i < n);65 return ev;66 }67 68 // Short Exponent Vectors are used for fast divisibility tests69 // ShortExpVectors "squeeze" an exponent vector into one word as follows:70 // Let n = BIT_SIZEOF_LONG / pVariables.71 // If n == 0 (i.e. pVariables > BIT_SIZE_OF_LONG), let m == the number72 // of non-zero exponents. If (m>BIT_SIZEOF_LONG), then sev = ~0, else73 // first m bits of sev are set to 1.74 // Otherwise (i.e. pVariables <= BIT_SIZE_OF_LONG)75 // represented by a bit-field of length n (resp. n+1 for some76 // exponents). If the value of an exponent is greater or equal to n, then77 // all of its respective n bits are set to 1. If the value of an exponent78 // is smaller than n, say m, then only the first m bits of the respective79 // n bits are set to 1, the others are set to 0.80 // This way, we have:81 // exp1 / exp2 ==> (ev1 & ~ev2) == 0, i.e.,82 // if (ev1 & ~ev2) then exp1 does not divide exp283 unsigned long p_GetShortExpVector(poly p, const ring r)84 {85 assume(p != NULL);86 if (p == NULL) return 0;87 unsigned long ev = 0; // short exponent vector88 unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp89 unsigned int m1; // highest bit which is filled with (n+1)90 unsigned int i = 0, j=1;91 92 if (n == 0)93 {94 if (r->N <2*BIT_SIZEOF_LONG)95 {96 n=1;97 m1=0;98 }99 else100 {101 for (; j<=(unsigned long) r->N; j++)102 {103 if (p_GetExp(p,j,r) > 0) i++;104 if (i == BIT_SIZEOF_LONG) break;105 }106 if (i>0)107 ev = ~((unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i));108 return ev;109 }110 }111 else112 {113 m1 = (n+1)*(BIT_SIZEOF_LONG - n*r->N);114 }115 116 n++;117 while (i<m1)118 {119 ev |= GetBitFields(p_GetExp(p, j,r), i, n);120 i += n;121 j++;122 }123 124 n--;125 while (i<BIT_SIZEOF_LONG)126 {127 ev |= GetBitFields(p_GetExp(p, j,r), i, n);128 i += n;129 j++;130 }131 return ev;132 }133 32 134 33 #endif // POLYS_IMPL_CC -
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 * -
libpolys/polys/monomials/p_polys.h
r98223c rf3094a 18 18 19 19 #include <omalloc/omalloc.h> 20 20 21 #include <misc/mylimits.h> 21 22 #include <misc/intvec.h> 22 23 #include <coeffs/coeffs.h> 23 24 25 #include <polys/monomials/monomials.h> 24 26 #include <polys/monomials/ring.h> 25 #include <polys/monomials/monomials.h>26 27 27 28 #include <polys/templates/p_MemAdd.h> -
libpolys/polys/monomials/ring.cc
r98223c rf3094a 5005 5005 } 5006 5006 5007 #ifdef PDEBUG 5008 int pDBsyzComp=0; 5009 #endif 5010 5007 5011 5008 5012 void rSetSyzComp(int k, const ring r)
Note: See TracChangeset
for help on using the changeset viewer.