Changeset c92fb1 in git


Ignore:
Timestamp:
May 29, 2009, 3:57:35 PM (15 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c7af8613769b29c741d6c338945669719f1fc4f8')
Children:
3f3b4d5bfcd72acaa4f578ac4ab804d36090b219
Parents:
667a9c0d30591ae4298e16548bf5886508bd3968
Message:
*motsak: more LL interface


git-svn-id: file:///usr/local/Singular/svn/trunk@11857 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/pInline2.h

    r667a9c rc92fb1  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pInline2.h,v 1.15 2008-08-08 08:55:22 Singular Exp $
     9 *  Version: $Id: pInline2.h,v 1.16 2009-05-29 13:57:35 motsak Exp $
    1010 *******************************************************************/
    1111#ifndef PINLINE2_H
     
    143143}
    144144
    145 
    146145#ifndef HAVE_EXPSIZES
    147146
    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!
     153PINLINE2 int p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
     154{
     155  pAssume2((VarOffset >> (24 + 6)) == 0);
    155156#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;
    159160  return exp;
    160161#else
    161162  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
     172PINLINE2 int p_SetExp(poly p, const int e, const unsigned long iBitmask, const int VarOffset)
     173{
    174174  pAssume2(e>=0);
    175   pAssume2((unsigned int) e<=r->bitmask);
     175  pAssume2((unsigned long) e<=iBitmask);
     176  pAssume2((VarOffset >> (24 + 6)) == 0);
    176177
    177178  // 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)*/;
    180181  // find the bits in the exponent vector
    181   register int offset = (r->VarOffset[v] & 0xffffff);
     182  register int offset = (VarOffset & 0xffffff);
    182183  // clear the bits in the exponent vector:
    183   p->exp[offset]  &= ~( r->bitmask << shift );
     184  p->exp[offset]  &= ~( iBitmask << shift );
    184185  // insert e with |
    185186  p->exp[ offset ] |= ee;
     
    187188}
    188189
    189 #else // #ifdef HAVE_EXPSIZES
    190 
    191 inline int BitMask(int bitmask, int twobits)
     190
     191#else // #ifdef HAVE_EXPSIZES // EXPERIMENTAL!!!
     192
     193PINLINE2 unsigned long BitMask(unsigned long bitmask, int twobits)
    192194{
    193195  // bitmask = 00000111111111111
     
    195197  // 1, 2, 3 - anything like 00011..11
    196198  pAssume2((twobits >> 2) == 0);
    197   const int _bitmasks[4] = {0xffffffff, 0x7fff, 0x7f, 0x3};
     199  const unsigned long _bitmasks[4] = {-1, 0x7fff, 0x7f, 0x3};
    198200  return bitmask & _bitmasks[twobits];
    199201}
    200202
    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
     205PINLINE2 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
    208209  int bitpos = hbyte & 0x3f; // last 6 bits
    209   int bitmask = BitMask(r->bitmask, hbyte >> 6);
     210  int bitmask = BitMask(iBitmask, hbyte >> 6);
    210211
    211212  int exp=(p->exp[pos] >> bitpos) & bitmask;
    212213  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
     217PINLINE2 int p_SetExp(poly p, const int e, const unsigned long iBitmask, const int VarOffset)
     218{
    229219  pAssume2(e>=0);
    230   pAssume2((unsigned int) e <= BitMask(r->bitmask, r->VarOffset[v] >> 30));
     220  pAssume2((unsigned long) e <= BitMask(iBitmask, VarOffset >> 30));
    231221
    232222  // 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);
    235225  register int shift = hbyte & 0x3f;
    236226  unsigned long ee = ((unsigned long)e) << shift;
    237227  // find the bits in the exponent vector
    238   register int offset = (r->VarOffset[v] & 0xffffff);
     228  register int offset = (VarOffset & 0xffffff);
    239229  // clear the bits in the exponent vector:
    240230  p->exp[offset]  &= ~( bitmask << shift );
     
    245235
    246236#endif // #ifndef HAVE_EXPSIZES
     237
     238
     239PINLINE2 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
     246PINLINE2 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
     256PINLINE2 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
     266PINLINE2 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
    247277
    248278// the following should be implemented more efficiently
Note: See TracChangeset for help on using the changeset viewer.