Changeset a539ad in git


Ignore:
Timestamp:
Feb 6, 2008, 10:12:47 AM (15 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cdfcdb8287f66bc6070028082cbbc6eff10e609b')
Children:
8f2bd1fc11ce18b5be7a734f75309011e212a4d3
Parents:
4dcfc0f02d5040e014133baff89ccfc1bbc383ed
Message:
kspoly.cc:
ksCreateShortSpoly: Speicher freigeben

kstd1.cc:
updateL: Speicher freigeben

kstd2.cc:
redRing2toM: Speicher freigeben
bba: Speicher freigeben
pLmFree(strat->P.lcm); moved down on level, please check

kutil.cc:
deleteInL: Speicher freigeben
eigene Routinen: Speicher freigeben

polys1.cc:
pContent: Speicher freigeben

rintegers.cc, rmodulon.cc: nNeg ist inplace Operation


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

Legend:

Unmodified
Added
Removed
  • kernel/kspoly.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kspoly.cc,v 1.12 2008-02-01 15:11:33 wienand Exp $ */
     4/* $Id: kspoly.cc,v 1.13 2008-02-06 09:12:45 wienand Exp $ */
    55/*
    66*  ABSTRACT -  Routines for Spoly creation and reductions
     
    346346  Exponent_t c;
    347347  poly m1,m2;
    348   number t1,t2;
     348  number t1 = NULL,t2 = NULL;
    349349  int cm,i;
    350350  BOOLEAN equal;
     
    352352#ifdef HAVE_RINGS
    353353  number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2);
    354   int ct = ksCheckCoeff(&lc1, &lc2); // gcd and zero divisors
    355354  if (rField_is_Ring(currRing))
    356355  {
     356    ksCheckCoeff(&lc1, &lc2); // gcd and zero divisors
    357357    if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
    358358    if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
     
    360360    {
    361361      pIter(a1);
     362      nDelete(&t2);
    362363      if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
    363364    }
     
    365366    {
    366367      pIter(a2);
     368      nDelete(&t1);
    367369      if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
    368370    }
     
    399401#ifdef HAVE_RINGS
    400402      if (rField_is_Ring(currRing))
     403      {
     404          nDelete(&lc1);
     405          nDelete(&lc2);
     406          nDelete(&t2);
    401407          pSetCoeff0(m2, t1);
     408      }
    402409      else
    403410#endif
     
    406413    }
    407414    else
     415    {
     416#ifdef HAVE_RINGS
     417    if (rField_is_Ring(currRing))
     418    {
     419      nDelete(&lc1);
     420      nDelete(&lc2);
     421      nDelete(&t1);
     422      nDelete(&t2);
     423    }
     424#endif
    408425      return NULL;
     426    }
    409427  }
    410428  if (a2==NULL)
     
    434452    p_Setm(m1, currRing);
    435453#ifdef HAVE_RINGS
    436       if (rField_is_Ring(currRing))
    437         pSetCoeff0(m1, t2);
     454    if (rField_is_Ring(currRing))
     455    {
     456      pSetCoeff0(m1, t2);
     457      nDelete(&lc1);
     458      nDelete(&lc2);
     459      nDelete(&t1);
     460    }
    438461    else
    439462#endif
     
    487510#ifdef HAVE_RINGS
    488511        if (rField_is_Ring(currRing))
     512        {
    489513          pSetCoeff0(m1, t2);
     514          nDelete(&lc1);
     515          nDelete(&lc2);
     516          nDelete(&t1);
     517        }
    490518        else
    491519#endif
     
    498526#ifdef HAVE_RINGS
    499527        if (rField_is_Ring(currRing))
    500             pSetCoeff0(m2, t1);
     528        {
     529          pSetCoeff0(m2, t1);
     530          nDelete(&lc1);
     531          nDelete(&lc2);
     532          nDelete(&t2);
     533        }
    501534        else
    502535#endif
     
    508541    if (rField_is_Ring(currRing))
    509542    {
    510       t1 = nSub(t1, t2);
    511       equal = nIsZero(t1);
    512       nDelete(&t2);
     543      equal = nEqual(t1,t2);
    513544    }
    514545    else
     
    526557#ifdef HAVE_RINGS
    527558      if (rField_is_Ring(currRing))
    528           pSetCoeff0(m1, t1);
     559      {
     560          pSetCoeff0(m1, nSub(t1, t2));
     561          nDelete(&lc1);
     562          nDelete(&lc2);
     563          nDelete(&t1);
     564          nDelete(&t2);
     565      }
    529566      else
    530567#endif
     
    537574    if (rField_is_Ring(currRing))
    538575    {
    539       nDelete(&t1);
    540       if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
    541       if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
     576      if (a2 != NULL)
     577      {
     578        nDelete(&t1);
     579        t1 = nMult(pGetCoeff(a2),lc1);
     580      }
     581      if (a1 != NULL)
     582      {
     583        nDelete(&t2);
     584        t2 = nMult(pGetCoeff(a1),lc2);
     585      }
    542586      while (a1 != NULL && nIsZero(t2))
    543587      {
    544588        pIter(a1);
    545         if (a1 != NULL) t2 = nMult(pGetCoeff(a1),lc2);
     589        if (a1 != NULL)
     590        {
     591          nDelete(&t2);
     592          t2 = nMult(pGetCoeff(a1),lc2);
     593        }
    546594      }
    547595      while (a2 != NULL && nIsZero(t1))
    548596      {
    549597        pIter(a2);
    550         if (a2 != NULL) t1 = nMult(pGetCoeff(a2),lc1);
     598        if (a2 != NULL)
     599        {
     600          nDelete(&t1);
     601          t1 = nMult(pGetCoeff(a2),lc1);
     602        }
    551603      }
    552604    }
     
    557609      if (a1==NULL)
    558610      {
     611#ifdef HAVE_RINGS
     612        if (rField_is_Ring(currRing))
     613        {
     614          nDelete(&lc1);
     615          nDelete(&lc2);
     616          nDelete(&t1);
     617          nDelete(&t2);
     618        }
     619#endif
    559620        p_LmFree(m1,currRing);
    560621        return NULL;
  • kernel/kstd1.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd1.cc,v 1.30 2007-11-09 11:31:52 Singular Exp $ */
     4/* $Id: kstd1.cc,v 1.31 2008-02-06 09:12:46 wienand Exp $ */
    55/*
    66* ABSTRACT:
     
    748748      if (pNext(strat->L[j].p) == strat->tail)
    749749      {
    750         pLmFree(strat->L[j].p);    /*deletes the short spoly and computes*/
     750#ifdef HAVE_RINGS
     751        if (rField_is_Ring(currRing))
     752          pLmDelete(strat->L[j].p);    /*deletes the short spoly and computes*/
     753        else
     754#else
     755          pLmFree(strat->L[j].p);    /*deletes the short spoly and computes*/
     756#endif
    751757        strat->L[j].p = NULL;
    752758        poly m1 = NULL, m2 = NULL;
  • kernel/kstd2.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd2.cc,v 1.57 2008-01-30 09:01:36 wienand Exp $ */
     4/* $Id: kstd2.cc,v 1.58 2008-02-06 09:12:46 wienand Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: alg. of Buchberger
     
    365365    if (h->GetLmTailRing() == NULL)
    366366    {
    367       if (h->lcm!=NULL) pLmFree(h->lcm);
     367      if (h->lcm!=NULL) pLmDelete(h->lcm);
    368368#ifdef KDEBUG
    369369      h->lcm=NULL;
     
    382382      if (at <= strat->Ll)
    383383      {
    384 #if 0
    385         if (kRingFindDivisibleByInS(strat->S, strat->sevS, strat->sl, h) < 0)
    386           return 1;
    387 #endif
    388384#ifdef KDEBUG
    389385        if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
     
    11111107    {
    11121108      // deletes the short spoly
    1113       pLmFree(strat->P.p);
     1109#ifdef HAVE_RINGS
     1110      if (rField_is_Ring(currRing))
     1111        pLmDelete(strat->P.p);
     1112      else
     1113#endif
     1114        pLmFree(strat->P.p);
    11141115      strat->P.p = NULL;
    11151116      poly m1 = NULL, m2 = NULL;
     
    12431244      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    12441245//      Print("[%d]",hilbeledeg);
    1245       if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
    12461246      if (strat->sl>srmax) srmax = strat->sl;
    12471247    }
     
    12501250      p_Delete(&strat->P.p2, currRing, strat->tailRing);
    12511251    }
     1252
     1253    if (strat->P.lcm!=NULL)
     1254#ifdef HAVE_RINGS
     1255      pLmDelete(strat->P.lcm);
     1256#else
     1257      pLmFree(strat->P.lcm);
     1258#endif
    12521259#ifdef KDEBUG
    12531260    memset(&(strat->P), 0, sizeof(strat->P));
  • kernel/kutil.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.77 2008-02-01 15:11:33 wienand Exp $ */
     4/* $Id: kutil.cc,v 1.78 2008-02-06 09:12:46 wienand Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    917917{
    918918  if (set[j].lcm!=NULL)
    919 #ifdef HAVE_RINGS_OLD
     919#ifdef HAVE_RINGS
    920920    if (pGetCoeff(set[j].lcm) != NULL)
    921921      pLmDelete(set[j].lcm);
     
    927927    if (pNext(set[j].p) == strat->tail)
    928928    {
    929 #ifdef HAVE_RINGS_OLD
     929#ifdef HAVE_RINGS
    930930      if (pGetCoeff(set[j].p) != NULL)
    931931        pLmDelete(set[j].p);
     
    10641064      strat->cp++;
    10651065      pLmDelete(Lp.lcm);
    1066       Lp.lcm=NULL;
    10671066      return;
    10681067  }
     
    10861085      strat->cp++;
    10871086      pLmDelete(Lp.lcm);
    1088       Lp.lcm=NULL;
    10891087      return;
    10901088  }
     
    11951193    }
    11961194#endif
     1195    pLmDelete(Lp.lcm);
    11971196    return;
    11981197  }
     
    12021201    // Is from a previous computed GB, therefore we know that spoly will
    12031202    // reduce to zero. Oliver.
     1203    WarnS("Could we come here? 8738947389");
    12041204    Lp.p=NULL;
    12051205  }
     
    12301230    *the first case is handeled in chainCrit
    12311231    */
    1232     if (Lp.lcm!=NULL) pLmDelete(Lp.lcm);
     1232    pLmDelete(Lp.lcm);
    12331233  }
    12341234  else
     
    26432643  {
    26442644    poly p = p_Copy(h->next, strat->tailRing);
     2645    number tmp = gcd;
    26452646    gcd = nIntDiv(0, gcd);
     2647    nDelete(&tmp);
    26462648    p = p_Mult_nn(p, gcd, strat->tailRing);
    26472649    nDelete(&gcd);
     
    27112713    }
    27122714  }
     2715  nDelete(&gcd);
    27132716}
    27142717
  • kernel/polys1.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys1.cc,v 1.30 2008-01-30 09:01:38 wienand Exp $ */
     4/* $Id: polys1.cc,v 1.31 2008-02-06 09:12:47 wienand Exp $ */
    55
    66/*
     
    482482{
    483483#ifdef HAVE_RINGS
    484   if (rField_is_Ring(currRing)) 
     484  if (rField_is_Ring(currRing))
    485485  {
    486486    if ((ph!=NULL) && rField_has_Units(currRing))
     
    489489      if (!nIsOne(k))
    490490      {
     491        number tmpGMP = k;
    491492        k = nInvers(k);
     493        nDelete(&tmpGMP);
    492494        poly h = pNext(ph);
    493         pSetCoeff0(ph, nMult(pGetCoeff(ph), k));
     495        pSetCoeff(ph, nMult(pGetCoeff(ph), k));
    494496        while (h != NULL)
    495497        {
     
    497499          pIter(h);
    498500        }
    499         nDelete(&k);
    500       }
     501      }
     502      nDelete(&k);
    501503    }
    502504    return;
  • kernel/rintegers.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: rintegers.cc,v 1.8 2008-02-01 15:16:14 wienand Exp $ */
     4/* $Id: rintegers.cc,v 1.9 2008-02-06 09:12:47 wienand Exp $ */
    55/*
    66* ABSTRACT: numbers modulo n
     
    235235number nrzNeg (number c)
    236236{
    237   int_number erg = (int_number) omAllocBin(gmp_nrz_bin); // evtl. spaeter mit bin
    238   mpz_init(erg);
    239   mpz_mul_si(erg, (int_number) c, -1);
    240   return (number) erg;
     237// nNeg inplace !!! TODO
     238//  int_number erg = (int_number) omAllocBin(gmp_nrn_bin); // evtl. spaeter mit bin
     239//  mpz_init(erg);
     240  mpz_mul_si((int_number) c, (int_number) c, -1);
     241  return c;
    241242}
    242243
  • kernel/rmodulon.cc

    r4dcfc0f ra539ad  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: rmodulon.cc,v 1.16 2008-02-01 15:16:15 wienand Exp $ */
     4/* $Id: rmodulon.cc,v 1.17 2008-02-06 09:12:47 wienand Exp $ */
    55/*
    66* ABSTRACT: numbers modulo n
     
    115115number nrnNeg (number c)
    116116{
    117   int_number erg = (int_number) omAllocBin(gmp_nrn_bin); // evtl. spaeter mit bin
    118   mpz_init(erg);
    119   mpz_sub(erg, nrnModul, (int_number) c);
    120   return (number) erg;
     117// nNeg inplace !!! TODO
     118//  int_number erg = (int_number) omAllocBin(gmp_nrn_bin); // evtl. spaeter mit bin
     119//  mpz_init(erg);
     120  mpz_sub((int_number) c, nrnModul, (int_number) c);
     121  return c;
    121122}
    122123
Note: See TracChangeset for help on using the changeset viewer.