Changeset c92fb1 in git
- Timestamp:
- May 29, 2009, 3:57:35 PM (14 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '7725b5cfc1eaf99630826ecc59f559d3b6831c24')
- Children:
- 3f3b4d5bfcd72acaa4f578ac4ab804d36090b219
- Parents:
- 667a9c0d30591ae4298e16548bf5886508bd3968
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/pInline2.h
r667a9c rc92fb1 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline2.h,v 1.1 5 2008-08-08 08:55:22 SingularExp $9 * Version: $Id: pInline2.h,v 1.16 2009-05-29 13:57:35 motsak Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE2_H … … 143 143 } 144 144 145 146 145 #ifndef HAVE_EXPSIZES 147 146 148 // exponent 149 // r->VarOffset encodes the position in p->exp (lower 24 bits) 150 // and number of bits to shift to the right in the upper 8 bits 151 PINLINE2 int p_GetExp(poly p, int v, ring r) 152 { 153 p_LmCheckPolyRing2(p, r); 154 pAssume2(v > 0 && v <= r->N); 147 /// get a single variable exponent 148 /// @Note: 149 /// the integer VarOffset encodes: 150 /// 1. the position of a variable in the exponent vector p->exp (lower 24 bits) 151 /// 2. number of bits to shift to the right in the upper 8 bits (which takes at most 6 bits for 64 bit) 152 /// Thus VarOffset always has 2 zero higher bits! 153 PINLINE2 int p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset) 154 { 155 pAssume2((VarOffset >> (24 + 6)) == 0); 155 156 #if 0 156 int pos=( r->VarOffset[v]& 0xffffff);157 int bitpos=( r->VarOffset[v]>> 24);158 int exp=(p->exp[pos] >> bitmask) & r->bitmask;157 int pos=(VarOffset & 0xffffff); 158 int bitpos=(VarOffset >> 24); 159 int exp=(p->exp[pos] >> bitmask) & iBitmask; 159 160 return exp; 160 161 #else 161 162 return (int) 162 ((p->exp[(r->VarOffset[v] & 0xffffff)] >> (r->VarOffset[v] >> 24)) 163 & r->bitmask); 164 #endif 165 } 166 167 // partial compare exponent 168 // r->VarOffset encodes the position in p->exp (lower 24 bits) 169 // and number of bits to shift to the right in the upper 8 bits 170 PINLINE2 int p_SetExp(poly p, int v, int e, ring r) 171 { 172 p_LmCheckPolyRing2(p, r); 173 pAssume2(v>0 && v <= r->N); 163 ((p->exp[(VarOffset & 0xffffff)] >> (VarOffset >> 24)) 164 & iBitmask); 165 #endif 166 } 167 168 169 /// set a single variable exponent 170 /// @Note: 171 /// VarOffset encodes the position in p->exp @see p_GetExp 172 PINLINE2 int p_SetExp(poly p, const int e, const unsigned long iBitmask, const int VarOffset) 173 { 174 174 pAssume2(e>=0); 175 pAssume2((unsigned int) e<=r->bitmask); 175 pAssume2((unsigned long) e<=iBitmask); 176 pAssume2((VarOffset >> (24 + 6)) == 0); 176 177 177 178 // shift e to the left: 178 register int shift = r->VarOffset[v]>> 24;179 unsigned long ee = ((unsigned long)e) << shift /*( r->VarOffset[v]>> 24)*/;179 register int shift = VarOffset >> 24; 180 unsigned long ee = ((unsigned long)e) << shift /*(VarOffset >> 24)*/; 180 181 // find the bits in the exponent vector 181 register int offset = ( r->VarOffset[v]& 0xffffff);182 register int offset = (VarOffset & 0xffffff); 182 183 // clear the bits in the exponent vector: 183 p->exp[offset] &= ~( r->bitmask << shift );184 p->exp[offset] &= ~( iBitmask << shift ); 184 185 // insert e with | 185 186 p->exp[ offset ] |= ee; … … 187 188 } 188 189 189 #else // #ifdef HAVE_EXPSIZES 190 191 inline int BitMask(int bitmask, int twobits) 190 191 #else // #ifdef HAVE_EXPSIZES // EXPERIMENTAL!!! 192 193 PINLINE2 unsigned long BitMask(unsigned long bitmask, int twobits) 192 194 { 193 195 // bitmask = 00000111111111111 … … 195 197 // 1, 2, 3 - anything like 00011..11 196 198 pAssume2((twobits >> 2) == 0); 197 const int _bitmasks[4] = {0xffffffff, 0x7fff, 0x7f, 0x3};199 const unsigned long _bitmasks[4] = {-1, 0x7fff, 0x7f, 0x3}; 198 200 return bitmask & _bitmasks[twobits]; 199 201 } 200 202 201 PINLINE2 int p_GetExp(poly p, int v, ring r) 202 { 203 p_LmCheckPolyRing2(p, r); 204 pAssume2(v > 0 && v <= r->N); 205 #if 1 // new!! 206 int pos =(r->VarOffset[v] & 0xffffff); 207 int hbyte= (r->VarOffset[v] >> 24); // the highest byte 203 204 /// @Note: we may add some more info (6 ) into VarOffset and thus encode 205 PINLINE2 int p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset) 206 { 207 int pos =(VarOffset & 0xffffff); 208 int hbyte= (VarOffset >> 24); // the highest byte 208 209 int bitpos = hbyte & 0x3f; // last 6 bits 209 int bitmask = BitMask( r->bitmask, hbyte >> 6);210 int bitmask = BitMask(iBitmask, hbyte >> 6); 210 211 211 212 int exp=(p->exp[pos] >> bitpos) & bitmask; 212 213 return exp; 213 #else 214 // old 215 return (int) 216 ((p->exp[(r->VarOffset[v] & 0xffffff)] >> (r->VarOffset[v] >> 24)) 217 & r->bitmask; 218 #endif 219 } 220 221 222 // partial compare exponent 223 // r->VarOffset encodes the position in p->exp (lower 24 bits) 224 // and number of bits to shift to the right in the upper 8 bits 225 PINLINE2 int p_SetExp(poly p, int v, int e, ring r) 226 { 227 p_LmCheckPolyRing2(p, r); 228 pAssume2(v>0 && v <= r->N); 214 215 } 216 217 PINLINE2 int p_SetExp(poly p, const int e, const unsigned long iBitmask, const int VarOffset) 218 { 229 219 pAssume2(e>=0); 230 pAssume2((unsigned int) e <= BitMask(r->bitmask, r->VarOffset[v]>> 30));220 pAssume2((unsigned long) e <= BitMask(iBitmask, VarOffset >> 30)); 231 221 232 222 // shift e to the left: 233 register int hbyte = r->VarOffset[v]>> 24;234 int bitmask = BitMask( r->bitmask, hbyte >> 6);223 register int hbyte = VarOffset >> 24; 224 int bitmask = BitMask(iBitmask, hbyte >> 6); 235 225 register int shift = hbyte & 0x3f; 236 226 unsigned long ee = ((unsigned long)e) << shift; 237 227 // find the bits in the exponent vector 238 register int offset = ( r->VarOffset[v]& 0xffffff);228 register int offset = (VarOffset & 0xffffff); 239 229 // clear the bits in the exponent vector: 240 230 p->exp[offset] &= ~( bitmask << shift ); … … 245 235 246 236 #endif // #ifndef HAVE_EXPSIZES 237 238 239 PINLINE2 int p_GetExp(const poly p, const ring r, const int VarOffset) 240 { 241 p_LmCheckPolyRing2(p, r); 242 pAssume2(VarOffset != -1); 243 return p_GetExp(p, r->bitmask, VarOffset); 244 } 245 246 PINLINE2 int p_SetExp(poly p, const int e, const ring r, const int VarOffset) 247 { 248 p_LmCheckPolyRing2(p, r); 249 pAssume2(VarOffset != -1); 250 return p_SetExp(p, e, r->bitmask, VarOffset); 251 } 252 253 254 255 /// get v^th exponent for a monomial 256 PINLINE2 int p_GetExp(const poly p, const int v, const ring r) 257 { 258 p_LmCheckPolyRing2(p, r); 259 pAssume2(v>0 && v <= r->N); 260 pAssume2(r->VarOffset[v] != -1); 261 return p_GetExp(p, r->bitmask, r->VarOffset[v]); 262 } 263 264 265 /// set v^th exponent for a monomial 266 PINLINE2 int p_SetExp(poly p, const int v, const int e, const ring r) 267 { 268 p_LmCheckPolyRing2(p, r); 269 pAssume2(v>0 && v <= r->N); 270 pAssume2(r->VarOffset[v] != -1); 271 return p_SetExp(p, e, r->bitmask, r->VarOffset[v]); 272 } 273 274 275 276 247 277 248 278 // the following should be implemented more efficiently
Note: See TracChangeset
for help on using the changeset viewer.