Changeset 52a5e8 in git for Singular/polys-impl.cc


Ignore:
Timestamp:
Dec 2, 1998, 2:57:41 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
a92ff6f3188bbc12d2a3689101ca97f48f880850
Parents:
5811fbf32c7285e5b584702b134e80d61f40e342
Message:
* new memory management scheme


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

Legend:

Unmodified
Added
Removed
  • Singular/polys-impl.cc

    r5811fb r52a5e8  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys-impl.cc,v 1.20 1998-11-10 17:25:32 Singular Exp $ */
     4/* $Id: polys-impl.cc,v 1.21 1998-12-02 13:57:39 obachman Exp $ */
    55
    66/***************************************************************
     
    2222#include "tok.h"
    2323#include "structs.h"
    24 #include "mmprivat.h"
     24#include "mmprivate.h"
    2525#include "mmemory.h"
    2626#include "febase.h"
     
    184184// currRing and r have the same number of variables, i.e. that polys
    185185// from r can be "fetched" into currRing
    186 #ifdef PDEBUG
     186#ifdef MDEBUG
    187187poly pDBFetchCopy(ring r, poly p,char *f,int l)
    188188#else
     
    195195  if (r->VarOffset == pVarOffset)
    196196  {
    197 #ifdef PDEBUG
     197#ifdef MDEBUG
    198198    res = a = pDBNew(f,l);
    199199#else
     
    206206    while (p!=NULL)
    207207    {
    208 #ifdef PDEBUG
     208#ifdef MDEBUG
    209209      a = pNext(a) = pDBNew(f,l);
    210210#else
     
    220220  else
    221221  {
    222 #ifdef PDEBUG
     222#ifdef MDEBUG
    223223    a = res = pDBInit(f,l);
    224224#else
     
    234234      // convert betweeen a lex order and a revlex order -- to speed
    235235      // up the sorting, we assemble new poly in inverse order
    236 #ifdef PDEBUG
     236#ifdef MDEBUG
    237237      res = pDBInit(f,l);
    238238#else
     
    263263 ***************************************************************/
    264264
    265 #ifdef PDEBUG
    266 poly pDBNew(char *f, int l)
    267 {
    268 #ifdef MDEBUG
    269   poly p = (poly) mmDBAllocSpecialized(f,l);
    270 #else
    271   poly p = (poly) mmAllocSpecialized();
    272 #endif
    273   memset(p,0,pMonomSize);
    274   return p;
    275 }
    276 #endif
    277265
    278266/*2
    279267* create a new monomial and init
    280268*/
    281 #ifdef PDEBUG
     269#ifdef MDEBUG
    282270poly pDBInit(char * f, int l)
    283271{
     
    293281* put the monomials in the freelist
    294282*/
    295 #ifdef PDEBUG
     283#ifdef MDEBUG
    296284void pDBDelete(poly * p, char * f, int l)
    297285{
     
    307295    pIter(h);
    308296#ifdef MDEBUG
    309     mmDBFreeSpecialized((ADDRESS)*p,f,l);
    310 #else
    311     mmFreeSpecialized((ADDRESS)*p);
     297    pDBFree1((ADDRESS)*p,f,l);
     298#else
     299    pFree1((ADDRESS)*p);
    312300#endif
    313301    *p=h;
     
    327315    pp=h;
    328316    pIter(h);
    329     mmFreeSpecialized((ADDRESS)pp);
     317    pFree1((ADDRESS)pp);
    330318  }
    331319  *p = NULL;
     
    336324* remove first monom
    337325*/
    338 #ifdef PDEBUG
     326#ifdef MDEBUG
    339327void pDBDelete1(poly * p, char * f, int l)
    340328{
     
    345333  *p = pNext(h);
    346334#ifdef MDEBUG
    347   mmDBFreeSpecialized((ADDRESS)h,f,l);
    348 #else
    349   mmFreeSpecialized((ADDRESS)h);
     335  pDBFree1((ADDRESS)h,f,l);
     336#else
     337  pFree1((ADDRESS)h);
    350338#endif
    351339}
     
    358346  nDelete(&(h->coef));
    359347  *p = pNext(h);
    360   mmFreeSpecialized((ADDRESS)h);
     348  pFree1((ADDRESS)h);
    361349}
    362350#endif
     
    371359
    372360/*2
    373 * remove first monom
    374 */
    375 #ifdef PDEBUG
    376 void pDBFree1(poly p, char * f, int l)
    377 {
    378   if (p!=NULL)
    379   {
    380     p->coef=NULL;//nDelete(&(p->coef));
    381 #ifdef MDEBUG
    382     mmDBFreeSpecialized((ADDRESS)p,f,l);
    383 #else
    384     mmFreeSpecialized((ADDRESS)p);
    385 #endif
    386   }
    387 }
    388 #endif
    389 
    390 /*2
    391361* creates a copy of p
    392362*/
    393 #ifdef PDEBUG
     363#ifdef MDEBUG
    394364poly pDBCopy(poly p,char *f,int l)
    395365#else
     
    401371  if (p==NULL) return NULL;
    402372  pDBTest(p,f,l);
    403 #ifdef PDEBUG
     373#ifdef MDEBUG
    404374  w = a = pDBNew(f,l);
    405375#else
     
    413383    do
    414384    {
    415 #ifdef PDEBUG
     385#ifdef MDEBUG
    416386      a = pNext(a) = pDBNew(f,l);
    417387#else
     
    433403* sets the coeff of the copy to a defined value
    434404*/
    435 #ifdef PDEBUG
     405#ifdef MDEBUG
    436406poly pDBCopy1(poly p,char *f,int l)
    437407#else
     
    440410{
    441411  poly w;
    442 #ifdef PDEBUG
     412#ifdef MDEBUG
    443413  w = pDBNew(f,l);
    444414#else
     
    454424* returns (a copy of) the head term of a
    455425*/
    456 #ifdef PDEBUG
     426#ifdef MDEBUG
    457427poly pDBHead(poly p,char *f, int l)
    458428#else
     
    464434  if (p!=NULL)
    465435  {
    466 #ifdef PDEBUG
     436#ifdef MDEBUG
    467437    w = pDBNew(f,l);
    468438#else
     
    484454* returns (a copy of) the head term of a without the coef
    485455*/
    486 #ifdef PDEBUG
     456#ifdef MDEBUG
    487457poly pDBHead0(poly p,char *f, int l)
    488458#else
     
    735705#endif // PDEBUG != 0
    736706
    737 
    738707BOOLEAN pDBTest(poly p, char *f, int l)
     708{
     709  return pDBTest(p, mm_specHeap, f,l);
     710}
     711
     712BOOLEAN pDBTest(poly p, memHeap tail_heap, memHeap lm_heap, char *f, int l)
     713{
     714  if (tail_heap != lm_heap && lm_heap != NULL)
     715  {
     716    poly pn = pNext(p);
     717    BOOLEAN ret;
     718    pNext(p) = NULL;
     719    ret = pDBTest(pn, tail_heap, f, l) && pDBTest(p, lm_heap, f, l);
     720    pNext(p) = pn;
     721    return ret;
     722  }
     723  else
     724  {
     725    return pDBTest(p, tail_heap, f, l);
     726  }
     727}
     728
     729BOOLEAN pDBTest(poly p, memHeap heap, char *f, int l)
    739730{
    740731  poly old=NULL;
     
    743734  {
    744735#ifdef MDEBUG
    745     if (!mmDBTestBlock(p,mm_specSize,f,l))
     736    if (!mmDBTestHeapBlock(p, heap, f,l))
    746737      return FALSE;
     738#elif defined(HEAP_DEBUG)
     739      if (! mmDebugCheckHeapAddr(p, heap, MM_HEAP_ADDR_USED_FLAG, f, l))
     740        return FALSE;
    747741#endif
    748742#ifdef LDEBUG
     
    818812#endif // PDEBUG
    819813
     814#define BIT_SIZEOF_LONG 8*SIZEOF_LONG
     815unsigned long GetBitFields(Exponent_t e,
     816                           unsigned int s, unsigned int n)
     817{
     818  unsigned int i = 0, ev = 0;
     819  assume(n > 0 && s < BIT_SIZEOF_LONG);
     820  do
     821  {
     822    assume(s+i < BIT_SIZEOF_LONG);
     823    if (e > (Exponent_t) i) ev |= Sy_bit(s+i);
     824    else break;
     825    i++;
     826  }
     827  while (i < n);
     828  return ev;
     829}
     830
     831unsigned long pGetShortExpVector(poly p)
     832{
     833  unsigned long ev = 0; // short exponent vector
     834  unsigned int n = BIT_SIZEOF_LONG / pVariables; // number of bits per exp
     835  unsigned int m1; // highest bit which is filled with (n+1)
     836  unsigned int i = 0, j=0;
     837 
     838  if (n == 0)
     839  {
     840    n = 1;
     841    m1 = 0;
     842  }
     843  else
     844  {
     845    m1 = (n+1)*(BIT_SIZEOF_LONG - n*pVariables);
     846  }
     847 
     848  n++;
     849  while (i<m1)
     850  {
     851    ev |= GetBitFields(p->exp[pVarLowIndex + j], i, n);
     852    i += n;
     853    j++;
     854  }
     855
     856  return ev;
     857}
    820858
    821859#endif // POLYS_IMPL_CC
Note: See TracChangeset for help on using the changeset viewer.