Changeset e977d9 in git


Ignore:
Timestamp:
Nov 4, 1998, 4:55:35 PM (26 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c7af8613769b29c741d6c338945669719f1fc4f8')
Children:
e06ef94705976eebd5f91b5f6535a90349f4b278
Parents:
b94bdef517fe4dd54a24a3ec2b16ffbe0759abbd
Message:
* access to single exponents using array of indicies


git-svn-id: file:///usr/local/Singular/svn/trunk@2632 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipid.h

    rb94bde re977d9  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: ipid.h,v 1.19 1998-10-22 12:26:13 krueger Exp $ */
     6/* $Id: ipid.h,v 1.20 1998-11-04 15:55:30 obachman Exp $ */
    77/*
    88* ABSTRACT: identfier handling
     
    1111#include "structs.h"
    1212#include "subexpr.h"
    13 //#include "polys-impl.h"
    1413
    1514struct sip_sring
     
    3736
    3837  // what follows below here should be set by rComplete, _only_
    39   short     VarOffset; /* controls indexing of exponents */
    40   short     VarCompIndex; /* controls locations of component in exp vector */
    41 
     38  int       *VarOffset;   /* controls indexing of exponents */
     39  short     VarCompIndex; /* location of component in exp vector */
     40  short     VarLowIndex;  /* lowest index of an exponent */
     41  short     VarHighIndex; /* Highest index of an expoentn */
     42 
    4243#ifdef RDEBUG
    4344  short      no; /* unique id for rings */
  • Singular/polys-impl.cc

    rb94bde re977d9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys-impl.cc,v 1.15 1998-04-07 18:37:41 Singular Exp $ */
     4/* $Id: polys-impl.cc,v 1.16 1998-11-04 15:55:32 obachman Exp $ */
    55
    66/***************************************************************
     
    3232/***************************************************************
    3333 *
    34  * Low - level routines for which deal with var indicies
     34 * Low - level routines which deal with var indicies
    3535 *
    3636 ***************************************************************/
     37// And here is how we determine the way exponents are stored:
     38// There are the following four possibilities:
     39//
     40//
     41// BIGENDIAN -- lex order
     42// e_1, e_2, ... , e_n,..,comp:  pVarOffset = -1,
     43//                               pVarLowIndex = 0,
     44//                               pVarHighIndex = pVariables-1
     45//                               pVarCompIndex = pVariables + #(..)
     46// BIGENDIAN -- rev lex order
     47// e_n, ... , e_2, e_1,..,comp:  pVarOffset = pVariables,
     48//                               pVarLowIndex = 0,
     49//                               pVarHighIndex = pVariables-1
     50//                               pVarCompIndex = pVariables + #(..)
     51// LITTLEENDIAN -- rev lex order
     52// comp,.., e_1, e_2, ... , e_n : pVarOffset = #(..),
     53//                                pVarLowIndex = 1 + #(..),
     54//                                pVarHighIndex = #(..) + pVariables
     55//                                pVarCompIndex = 0
     56// LITTLEENDIAN -- lex order
     57// comp,..,e_n, .... , e_2, e_1 : pVarOffset = pVariables + 1 + #(..)
     58//                                pVarLowIndex = 1 + #(..)
     59//                                pVarHighIndex = #(..) + pVariables
     60//                                pVarCompIndex = 0
     61//
     62// Furthermore, the size of the exponent vector is always a multiple
     63// of the word size -- "empty exponents" (exactly #(..) ones) are
     64// filled in between comp and first/last exponent -- i.e. comp and
     65// first/last exponent might not be next to each other
     66
     67void pGetVarIndicies_Lex(int nvars, int* VarOffset, int &VarCompIndex,
     68                                int &VarLowIndex, int &VarHighIndex)
     69{
     70  long temp = (nvars+1)*sizeof(Exponent_t);
     71  if ((temp % sizeof(long)) == 0)
     72    temp = temp / sizeof(long);
     73  else
     74    temp = (temp / sizeof(long)) + 1; // temp == pVariables1W
     75#ifdef WORDS_BIGENDIAN
     76  VarCompIndex = temp * sizeof(long)/sizeof(Exponent_t) - 1;
     77  VarOffset[0] = VarCompIndex;
     78  for (temp=1; temp<=nvars; temp++)
     79    Varoffset[temp] = temp - 1;
     80  VarLowIndex  = 0;
     81  VarHighIndex = nvars - 1;
     82#else //  ! WORDS_BIGENDIAN
     83  temp *= sizeof(long)/sizeof(Exponent_t);
     84  VarHighIndex = temp -1;
     85  VarLowIndex = temp - nvars;
     86  VarOffset[0] = 0;
     87  for (long i = 1; i<=nvars;i++)
     88    VarOffset[i] = temp - i;
     89  VarCompIndex = 0;
     90#endif // WORDS_BIGENDIAN
     91}
     92
     93void pGetVarIndicies_RevLex(int nvars,int *VarOffset,int &VarCompIndex,
     94                            int &VarLowIndex, int &VarHighIndex)
     95{
     96  long temp = (nvars+1)*sizeof(Exponent_t);
     97  if ((temp % sizeof(long)) == 0)
     98    temp = temp / sizeof(long);
     99  else
     100    temp = (temp / sizeof(long)) + 1; // temp == pVariables1W
     101#ifdef WORDS_BIGENDIAN
     102  VarCompIndex = temp * sizeof(long)/sizeof(Exponent_t) - 1;
     103  VarOffset[0] = VarCompIndex;
     104  for (temp=1; temp <= nvars; temp++)
     105    VarOffset[temp] = nvars - temp;
     106  VarLowIndex  = 0;
     107  VarHighIndex = nvars-1;
     108#else //  ! WORDS_BIGENDIAN
     109  temp *= sizeof(long)/sizeof(Exponent_t);
     110  VarHighIndex = temp -1;
     111  VarLowIndex = temp - nvars;
     112  VarOffset[0] = 0;
     113  for (int i = 1; i<=nvars; i++)
     114    VarOffset[i] = temp - nvars - 1 + i;
     115  VarCompIndex = 0;
     116#endif // WORDS_BIGENDIAN
     117}
     118
     119void pGetVarIndicies(int nvars, int *VarOffset, int &VarCompIndex,
     120                     int &VarLowIndex, int &VarHighIndex)
     121{
     122  pGetVarIndicies_Lex(nvars,VarOffset, VarCompIndex, VarLowIndex,VarHighIndex);
     123}
     124
    37125// gets var indicies w.r.t. the ring r
    38 void pGetVarIndicies(ring r, int &VarOffset, int &VarCompIndex,
     126void pGetVarIndicies(ring r, int *VarOffset, int &VarCompIndex,
    39127                     int &VarLowIndex, int &VarHighIndex)
    40128{
     
    590678    Print("Error in pCopyMonAddFast in %s:%d\n", f, l);
    591679  pFree1(ptemp);
     680  pTest(p1);
    592681}
    593682
  • Singular/polys-impl.h

    rb94bde re977d9  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: polys-impl.h,v 1.24 1998-10-15 11:46:06 obachman Exp $ */
     6/* $Id: polys-impl.h,v 1.25 1998-11-04 15:55:32 obachman Exp $ */
    77
    88/***************************************************************
     
    6464// Ceiling((pVariables) / sizeof(void*))
    6565extern int pVariablesW;
    66 extern int pVarOffset;
     66extern int *pVarOffset;
    6767extern int pVarLowIndex;
    6868extern int pVarHighIndex;
     
    7474 *
    7575 ***************************************************************/
    76 // And here is how we determine the way exponents are stored:
    77 // There are the following four possibilities:
    78 //
    79 //
    80 // BIGENDIAN -- lex order
    81 // e_1, e_2, ... , e_n,..,comp:  pVarOffset = -1,
    82 //                               pVarLowIndex = 0,
    83 //                               pVarHighIndex = pVariables-1
    84 //                               pVarCompIndex = pVariables + #(..)
    85 // BIGENDIAN -- rev lex order
    86 // e_n, ... , e_2, e_1,..,comp:  pVarOffset = pVariables,
    87 //                               pVarLowIndex = 0,
    88 //                               pVarHighIndex = pVariables-1
    89 //                               pVarCompIndex = pVariables + #(..)
    90 // LITTLEENDIAN -- rev lex order
    91 // comp,.., e_1, e_2, ... , e_n : pVarOffset = #(..),
    92 //                                pVarLowIndex = 1 + #(..),
    93 //                                pVarHighIndex = #(..) + pVariables
    94 //                                pVarCompIndex = 0
    95 // LITTLEENDIAN -- lex order
    96 // comp,..,e_n, .... , e_2, e_1 : pVarOffset = pVariables + 1 + #(..)
    97 //                                pVarLowIndex = 1 + #(..)
    98 //                                pVarHighIndex = #(..) + pVariables
    99 //                                pVarCompIndex = 0
    100 //
    101 // Furthermore, the size of the exponent vector is always a multiple
    102 // of the word size -- "empty exponents" (exactly #(..) ones) are
    103 // filled in between comp and first/last exponent -- i.e. comp and
    104 // first/last exponent might not be next to each other
    105 
    106 #ifdef WORDS_BIGENDIAN
    107 
    108 #define _pHasReverseExp     (pVarOffset != -1)
    109 
    110 #define _pExpIndex(i)                           \
    111   (pVarOffset == -1 ? (i) - 1 : pVarOffset - (i))
    112 #define _pRingExpIndex(r, i)                           \
    113   ((r)->VarOffset == -1 ? (i) - 1 : (r)->VarOffset - (i))
    114 
    115 #define _pCompIndex        pVarCompIndex
    116 #define _pRingCompIndex(r)  (r->VarCompIndex)
    117 
    118 #else // ! WORDS_BIGENDIAN
    119 
    120 #define _pHasReverseExp    (pVarOffset > (SIZEOF_LONG / SIZEOF_EXPONENT) - 1)
    121 
    122 #define _pExpIndex(i)                                   \
    123   (pVarOffset > (SIZEOF_LONG / SIZEOF_EXPONENT) - 1?   \
    124    pVarOffset - (i) : pVarOffset + (i))
    125 #define _pRingExpIndex(r, i)                                \
    126   ((r)->VarOffset > (SIZEOF_LONG / SIZEOF_EXPONENT) - 1?   \
    127    (r)->VarOffset - (i) : (r)->VarOffset + (i))
    128 
    129 #define _pCompIndex          0
    130 #define _pRingCompIndex(r)   0
    131 
    132 #endif // WORDS_BIGENDIAN
    133 
    134 inline void pGetVarIndicies_Lex(int nvars, int &VarOffset, int &VarCompIndex,
    135                                 int &VarLowIndex, int &VarHighIndex)
    136 {
    137   long temp = (nvars+1)*sizeof(Exponent_t);
    138   if ((temp % sizeof(long)) == 0)
    139     temp = temp / sizeof(long);
    140   else
    141     temp = (temp / sizeof(long)) + 1; // temp == pVariables1W
    142 #ifdef WORDS_BIGENDIAN
    143   VarCompIndex = temp * sizeof(long)/sizeof(Exponent_t) - 1;
    144   VarOffset    = -1;
    145   VarLowIndex  = 0;
    146   VarHighIndex = nvars - 1;
    147 #else //  ! WORDS_BIGENDIAN
    148   temp *= sizeof(long)/sizeof(Exponent_t);
    149   VarHighIndex = temp -1;
    150   VarLowIndex = temp - nvars;
    151   VarOffset = temp;
    152   VarCompIndex = 0;
    153 #endif // WORDS_BIGENDIAN
    154 }
    155 
    156 #define pSetVarIndicies_Lex(nvars)                      \
    157   pGetVarIndicies_Lex(nvars,pVarOffset,pVarCompIndex,   \
    158                       pVarLowIndex,pVarHighIndex)
    159 
    160 
    161 
    162 inline void pGetVarIndicies_RevLex(int nvars,int &VarOffset,int &VarCompIndex,
    163                                    int &VarLowIndex, int &VarHighIndex)
    164 {
    165   long temp = (nvars+1)*sizeof(Exponent_t);
    166   if ((temp % sizeof(long)) == 0)
    167     temp = temp / sizeof(long);
    168   else
    169     temp = (temp / sizeof(long)) + 1; // temp == pVariables1W
    170 #ifdef WORDS_BIGENDIAN
    171   VarCompIndex = temp * sizeof(long)/sizeof(Exponent_t) - 1;
    172   VarOffset    = nvars;
    173   VarLowIndex  = 0;
    174   VarHighIndex = nvars-1;
    175 #else //  ! WORDS_BIGENDIAN
    176   temp *= sizeof(long)/sizeof(Exponent_t);
    177   VarHighIndex = temp -1;
    178   VarLowIndex = temp - nvars;
    179   VarOffset = temp - nvars -1;
    180   VarCompIndex = 0;
    181 #endif // WORDS_BIGENDIAN
    182 }
    183 
    184 #define pSetVarIndicies_RevLex(nvars)                   \
    185  pGetVarIndicies_RevLex(nvars,pVarOffset,pVarCompIndex, \
    186                         pVarLowIndex,pVarHighIndex)
    187 
    188 // The default settings:
    189 inline void pGetVarIndicies(int nvars, int &VarOffset, int &VarCompIndex,
    190                             int &VarLowIndex, int &VarHighIndex)
    191 {
    192   pGetVarIndicies_Lex(nvars,VarOffset, VarCompIndex, VarLowIndex,VarHighIndex);
    193 }
    194 // gets var indicies w.r.t. the ring r
    195 extern void pGetVarIndicies(ring r, int &VarOffset, int &VarCompIndex,
     76#define _pExpIndex(i) pVarOffset[(i)]
     77#define _pRingExpIndex(r, i)  (r)->VarOffset[(i)]
     78
     79#define _pCompIndex        pVarOffset[0]
     80#define _pRingCompIndex(r)  ((r)->VarOffset[0])
     81
     82// for simple, lex orderings 
     83extern void pGetVarIndicies_Lex(int nvars, int* VarOffset, int &VarCompIndex,
     84                                int &VarLowIndex, int &VarHighIndex);
     85// for simple, revlex orderings
     86extern void pGetVarIndicies_RevLex(int nvars,int *VarOffset,int &VarCompIndex,
     87                                   int &VarLowIndex, int &VarHighIndex);
     88// for all non-simple orderings
     89extern void pGetVarIndicies(int nvars, int *VarOffset, int &VarCompIndex,
    19690                            int &VarLowIndex, int &VarHighIndex);
    197 
    198 #define pSetVarIndicies(nvars)                      \
    199   pGetVarIndicies(nvars, pVarOffset, pVarCompIndex, \
    200                   pVarLowIndex, pVarHighIndex)
    201 
     91// gets var indicies w.r.t. the ring r --
     92// determines which one of three pGetVarIndicies((int nvars, ...) to use
     93// based on properties of r
     94extern void pGetVarIndicies(ring r, int *VarOffset, int &VarCompIndex,
     95                            int &VarLowIndex, int &VarHighIndex);
    20296
    20397/***************************************************************
     
    276170inline void _pGetExpV(poly p, Exponent_t *ev)
    277171{
    278   if (_pHasReverseExp)
    279   {
    280     for (int i = pVarLowIndex, j = pVariables; j; i++, j--)
    281       ev[j] = p->exp[i];
    282   }
    283   else
    284     memcpy(&ev[1], &(p->exp[pVarLowIndex]), pVariables*sizeof(Exponent_t));
     172  for (int j = pVariables; j; j--)
     173      ev[j] = _pGetExp(p, j);
     174
    285175  ev[0] = _pGetComp(p);
    286176}
     
    289179inline void _pSetExpV(poly p, Exponent_t *ev)
    290180{
    291   if (_pHasReverseExp)
    292   {
    293     for (int i = pVarLowIndex, j = pVariables; j; i++, j--)
    294       p->exp[i] = ev[j];
    295   }
    296   else
    297     memcpy(&(p->exp[pVarLowIndex]), &ev[1], pVariables*sizeof(Exponent_t));
     181  for (int j = pVariables; j; j--)
     182      _pSetExp(p, j, ev[j]);
     183
    298184  _pSetComp(p, ev[0]);
    299185  pSetm(p);
     
    649535#define _pExpQuerSum(p)  __pExpQuerSum2(p, pVarLowIndex, pVarHighIndex)
    650536
    651 #define _pExpQuerSum1(p,to)                             \
    652  (_pHasReverseExp ?                                     \
    653     __pExpQuerSum2(p, _pExpIndex(to), _pExpIndex(1)) :  \
    654     __pExpQuerSum2(p, _pExpIndex(1), _pExpIndex(to)))
    655 
    656 #define _pExpQuerSum2(p,from,to)                            \
    657  (_pHasReverseExp ?                                         \
    658     __pExpQuerSum2(p, _pExpIndex(to), _pExpIndex(from)) :   \
    659     __pExpQuerSum2(p, _pExpIndex(from), _pExpIndex(to)))
     537inline int _pExpQuerSum1(poly p, int to)
     538{
     539  int ei_to = _pExpIndex(to);
     540  int ei_1 = _pExpIndex(1);
     541 
     542  if (ei_1 > ei_to)
     543    return __pExpQuerSum2(p, ei_to, ei_1);
     544  else
     545    return __pExpQuerSum2(p, ei_1, ei_to);
     546}
     547
     548
     549inline int _pExpQuerSum2(poly p,int from,int to)
     550{
     551  int ei_to = _pExpIndex(to);
     552  int ei_from = _pExpIndex(from);
     553 
     554  if (ei_from > ei_to)
     555    return __pExpQuerSum2(p, ei_to, ei_from);
     556  else
     557    return __pExpQuerSum2(p, ei_from, ei_to);
     558}
    660559
    661560#endif // POLYS_IMPL_H
  • Singular/polys.cc

    rb94bde re977d9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys.cc,v 1.32 1998-09-24 10:46:22 Singular Exp $ */
     4/* $Id: polys.cc,v 1.33 1998-11-04 15:55:34 obachman Exp $ */
    55
    66/*
     
    4040int pMonomSizeW;    // size of monom (in words)
    4141int pLexSgn;        // 1, for lex monom comps; -1 otherwise (exception: ls)
    42 int pVarOffset;     // controls the way exponents are stored in a vector
     42int *pVarOffset;     // controls the way exponents are stored in a vector
    4343int pVarLowIndex;   // lowest exponent index
    4444int pVarHighIndex;  // highest exponent index
     
    981981      case ringorder_ls:
    982982      case ringorder_unspec:
    983         pSetVarIndicies_RevLex(pVariables);
     983        pGetVarIndicies_RevLex(pVariables, pVarOffset, pVarCompIndex,
     984                               pVarLowIndex, pVarHighIndex);
    984985        pLexSgn = -1;
    985986        if (comp_order == ringorder_C || o_r == ringorder_unspec)
     
    10031004      default:
    10041005#endif
    1005         pSetVarIndicies_Lex(pVariables);
     1006        pGetVarIndicies_Lex(pVariables, pVarOffset, pVarCompIndex,
     1007                            pVarLowIndex, pVarHighIndex);
    10061008        pLexSgn = 1;
    10071009        if (comp_order == ringorder_c)
     
    10271029    pLDeg = ldeg1c;
    10281030    if (o_r == ringorder_ls)
    1029       pSetVarIndicies_Lex(pVariables);
     1031      pGetVarIndicies_Lex(pVariables, pVarOffset, pVarCompIndex,
     1032                          pVarLowIndex, pVarHighIndex);
     1033
    10301034  }
    10311035}
     
    10441048      case ringorder_ls:
    10451049      case ringorder_ws:
    1046         pSetVarIndicies_RevLex(pVariables);
     1050        pGetVarIndicies_RevLex(pVariables, pVarOffset, pVarCompIndex,
     1051                               pVarLowIndex, pVarHighIndex);
    10471052        pLexSgn = -1;
    10481053        *p = pComp_otCOMPEXP;
     
    10581063      default:
    10591064#endif
    1060         pSetVarIndicies_Lex(pVariables);
     1065        pGetVarIndicies_Lex(pVariables, pVarOffset, pVarCompIndex,
     1066                            pVarLowIndex, pVarHighIndex);
    10611067        pLexSgn = 1;
    10621068        *p = pComp_otCOMPEXP;
     
    10731079    pLDeg = ldeg1c;
    10741080    if (o_r == ringorder_ls)
    1075      pSetVarIndicies_Lex(pVariables);
     1081        pGetVarIndicies_Lex(pVariables, pVarOffset, pVarCompIndex,
     1082                            pVarLowIndex, pVarHighIndex);
    10761083  }
    10771084}
     
    12061213  tmpR.block1 = b1;
    12071214  tmpR.wvhdl = wv;
     1215  rComplete(&tmpR);
    12081216  pSetGlobals(&tmpR);
    12091217}
     
    12421250  }
    12431251
    1244   // Set default Var Indicies
    1245   pSetVarIndicies(pVariables);
    1246 
    12471252  // Initialize memory management
    12481253  mmSpecializeBlock(pMonomSize);
    12491254
     1255  pVarOffset = r->VarOffset;
     1256 
    12501257  pOrdSgn = r->OrdSgn;
    12511258  pVectorOut=(r->order[0]==ringorder_c);
     
    12901297  else
    12911298  {
     1299    pGetVarIndicies(pVariables, pVarOffset, pVarCompIndex, pVarLowIndex,
     1300                    pVarHighIndex);
    12921301    //pLexOrder=TRUE;
    12931302    pVectorOut=order[0]==ringorder_c;
  • Singular/ring.cc

    rb94bde re977d9  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.34 1998-11-02 09:05:40 Singular Exp $ */
     4/* $Id: ring.cc,v 1.35 1998-11-04 15:55:35 obachman Exp $ */
    55
    66/*
     
    671671void rComplete(ring r)
    672672{
    673   int VarCompIndex, VarOffset, dummy;
    674   pGetVarIndicies(r, VarOffset, VarCompIndex, dummy, dummy);
    675   r->VarOffset = (short) VarOffset;
    676   r->VarCompIndex = (short) VarCompIndex;
     673  int VarCompIndex, VarLowIndex, VarHighIndex;
     674 
     675  r->VarOffset = (int*) Alloc((r->N + 1)*sizeof(int));
     676  pGetVarIndicies(r, r->VarOffset, VarCompIndex,
     677                  VarLowIndex, VarHighIndex);
     678  r->VarCompIndex = VarCompIndex;
     679  r->VarLowIndex = VarLowIndex;
     680  r->VarHighIndex = VarHighIndex;
    677681}
    678682
     
    928932        Free((ADDRESS)r->parameter,r->P*sizeof(char *));
    929933      }
     934      Free((ADDRESS)r->VarOffset, (r->N +1)*sizeof(int));
    930935    }
    931936#ifdef TEST
     
    17851790  res->idroot = NULL;
    17861791  if (r->qideal!=NULL) res->qideal= idCopy(r->qideal);
     1792  res->VarOffset = (int*) Alloc((r->N + 1)*sizeof(int));
     1793  memcpy4(res->VarOffset, r->VarOffset, (r->N + 1)*sizeof(int));
    17871794
    17881795#ifdef RDEBUG
Note: See TracChangeset for help on using the changeset viewer.