Changeset 416465 in git for Singular/syz.cc


Ignore:
Timestamp:
Nov 15, 1999, 6:20:58 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
Children:
721650e849298f036e56d58feb3f554f1bd4d84b
Parents:
57e94c4a2330bb253fb2189a2502d15dabe880e9
Message:
* bug-fixes from work with Thomas


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

Legend:

Unmodified
Added
Removed
  • Singular/syz.cc

    r57e94c4 r416465  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: syz.cc,v 1.27 1999-10-22 11:14:18 obachman Exp $ */
     4/* $Id: syz.cc,v 1.28 1999-11-15 17:20:52 obachman Exp $ */
    55
    66/*
     
    2626#include "ring.h"
    2727#include "syz.h"
     28#include "prCopy.h"
     29
    2830
    2931void syDeleteRes(resolvente * res,int length)
     
    131133* in the module below--*/
    132134  searchUnit = TRUE;
     135  int curr_syz_limit = rGetCurrSyzLimit();
    133136  while (searchUnit)
    134137  {
     
    211214      pDelete(&Unit1);
    212215//--deletes superfluous elements from the module below---
    213       pDelete(&(mod->m[ModComp-1]));
    214       for (k=ModComp-1;k<IDELEMS(mod)-1;k++)
     216      pDelete(&(mod->m[ModComp-1 - curr_syz_limit]));
     217      for (k=ModComp-1 - curr_syz_limit;k<IDELEMS(mod)-1;k++)
    215218        mod->m[k] = mod->m[k+1];
    216219      mod->m[IDELEMS(mod)-1] = NULL;
     
    229232* make Gauss for one element
    230233*/
    231 static void syGaussForOne(ideal syz, int elnum, int ModComp)
     234void syGaussForOne(ideal syz, int elnum, int ModComp,int from,int till)
    232235{
    233236  int k,j,i,lu;
     
    235238  poly actWith=syz->m[elnum];
    236239
     240  if (from<0) from = 0;
     241  if ((till<=0) || (till>IDELEMS(syz))) till = IDELEMS(syz);
    237242  syz->m[elnum] = NULL;
    238243  if (!rField_has_simple_inverse()) pCleardenom(actWith);
    239244/*--makes Gauss alg. for the column ModComp--*/
    240   //unit1 = pTakeOutComp1(&(actWith), ModComp);
    241245  pTakeOutComp(&(actWith), ModComp, &unit1, &lu);
    242   k=0;
    243   while (k<IDELEMS(syz))
    244   {
    245     if (syz->m[k]!=NULL)
    246     {
    247       //unit2 = pTakeOutComp1(&(syz->m[k]), ModComp);
    248       pTakeOutComp(&(syz->m[k]), ModComp, &unit2, &lu);
    249       syz->m[k] = pMult(syz->m[k],pCopy(unit1));
    250       syz->m[k] = pSub(syz->m[k],
     246  while (from<till)
     247  {
     248    if (syz->m[from]!=NULL)
     249    {
     250      pTakeOutComp(&(syz->m[from]), ModComp, &unit2, &lu);
     251      syz->m[from] = pMult(syz->m[from],pCopy(unit1));
     252      syz->m[from] = pSub(syz->m[from],
    251253        pMult(pCopy(actWith),unit2));
    252       if (syz->m[k]==NULL)
    253       {
    254         PrintS("Hier muss noch was gemacht werden\n");
    255       }
    256     }
    257     k++;
     254    }
     255    from++;
    258256  }
    259257  pDelete(&actWith);
     
    383381  if (res[syzIndex]!=NULL)
    384382    syMinStep(res[syzIndex-1],res[syzIndex]);
     383  if (!idIs0(res[0]))
     384    idMinEmbedding(res[0]);
    385385}
    386386
     
    403403  tHomog hom=isNotHomog;
    404404  ideal temp=NULL;
    405   intvec *w,*w1=NULL,**tempW;
    406   int i,k,syzIndex = 0,j;
     405  intvec *w = NULL,**tempW;
     406  int i,k,syzIndex = 0,j,rk_arg=max(1,idRankFreeModule(arg));
    407407  int Kstd1_OldDeg=Kstd1_deg;
    408408  BOOLEAN completeMinim;
     
    420420  }
    421421  res = (resolvente)Alloc0((*length)*sizeof(ideal));
    422   res[0] = idCopy(arg);
     422
     423/*--- initialize the syzygy-ring -----------------------------*/
     424  ring origR = currRing;
     425  ring syz_ring = rCurrRingAssureSyzComp();
     426  rSetSyzComp(rk_arg);
     427 
     428  if (syz_ring != origR)
     429  {
     430    res[0] = idrCopyR_NoSort(arg, origR);
     431  }
     432  else
     433  {
     434    res[0] = idCopy(arg);
     435  }
     436 
     437/*--- creating weights for the module components ---------------*/
    423438  if ((weights==NULL) || (*weights==NULL) || ((*weights)[0]==NULL))
    424439  {
     
    440455  if (hom==isHomog)
    441456  {
    442     w1 = syPrepareModComp(res[0],&w);
     457    intvec *w1 = syPrepareModComp(res[0],&w);
    443458    if (w!=NULL) { delete w;w=NULL; }
    444   }
     459    w = w1;
     460  }
     461   
     462/*--- the main loop --------------------------------------*/
    445463  while ((!idIs0(res[syzIndex])) &&
    446464         ((maxlength==-1) || (syzIndex<=maxlength)))
    447465   // (syzIndex<maxlength+(int)minim)))
    448   /*compute one step more for minimizing*/
     466/*--- compute one step more for minimizing-----------------*/
    449467  {
    450468    if (Kstd1_deg!=0) Kstd1_deg++;
     
    465483      *weights = tempW;
    466484    }
     485/*--- interreducing first -----------------------------------*/
    467486    if (minim || (syzIndex!=0))
    468487    {
     488      if (syzIndex>0)
     489      {
     490        int rkI=idRankFreeModule(res[syzIndex]);
     491        rSetSyzComp(rkI);
     492      }
    469493      temp = kInterRed(res[syzIndex],currQuotient);
    470494      idDelete(&res[syzIndex]);
     
    473497    }
    474498    temp = NULL;
     499/*--- computing the syzygy modules --------------------------------*/
    475500    if ((currQuotient==NULL)&&(syzIndex==0)&& (!TEST_OPT_DEGBOUND))
    476501    {
    477       res[/*syzIndex+*/1] = idSyzygies(res[0/*syzIndex*/],
    478         NULL/*currQuotient*/,hom,&w1,TRUE,Kstd1_deg);
     502      res[/*syzIndex+*/1] = idSyzygies(res[0/*syzIndex*/],hom,&w,FALSE,TRUE,Kstd1_deg);
    479503      if ((!TEST_OPT_NOTREGULARITY) && (Kstd1_deg>0)) test |= Sy_bit(OPT_DEGBOUND);
    480504    }
    481505    else
    482       res[syzIndex+1] = idSyzygies(res[syzIndex],currQuotient,hom,&w1);
     506    {
     507        res[syzIndex+1] = idSyzygies(res[syzIndex],hom,&w,FALSE);
     508    }
    483509    completeMinim=(syzIndex!=maxlength) || (maxlength ==-1) || (hom!=isHomog);
    484510    syzIndex++;
     
    491517      idDelete(&res[syzIndex]);
    492518    }
     519/*---creating the iterated weights for module components ---------*/
    493520    if ((hom == isHomog) && (!idIs0(res[syzIndex])))
    494521    {
     
    496523//w1->show();
    497524//PrintLn();
    498       k = idRankFreeModule(res[syzIndex]);
    499       w = NewIntvec1(k+IDELEMS(res[syzIndex]));
     525      int max_comp = idRankFreeModule(res[syzIndex]);
     526      k = max_comp - rGetCurrSyzLimit();
     527      assume(w != NULL);
     528      if (w != NULL)
     529        w->resize(max_comp+IDELEMS(res[syzIndex]));
     530      else
     531        w = NewIntvec1(max_comp+IDELEMS(res[syzIndex]));
    500532      (*weights)[syzIndex] = NewIntvec1(k);
    501533      for (i=0;i<k;i++)
     
    503535        if (res[syzIndex-1]->m[i]!=NULL) // hs
    504536        {
    505           (*w)[i] = pFDeg(res[syzIndex-1]->m[i]);
     537          (*w)[i + rGetCurrSyzLimit()] = pFDeg(res[syzIndex-1]->m[i]);
    506538          if (pGetComp(res[syzIndex-1]->m[i])>0)
    507             (*w)[i] += (*w1)[pGetComp(res[syzIndex-1]->m[i])-1];
    508           (*((*weights)[syzIndex]))[i] = (*w)[i];
     539            (*w)[i + rGetCurrSyzLimit()]
     540              += (*w)[pGetComp(res[syzIndex-1]->m[i])-1];
     541          (*((*weights)[syzIndex]))[i] = (*w)[i+rGetCurrSyzLimit()];
    509542        }
    510543      }
     
    512545      {
    513546        if (res[syzIndex]->m[i-k]!=NULL)
    514           (*w)[i] = pFDeg(res[syzIndex]->m[i-k])
     547          (*w)[i+rGetCurrSyzLimit()] = pFDeg(res[syzIndex]->m[i-k])
    515548                    +(*w)[pGetComp(res[syzIndex]->m[i-k])-1];
    516549      }
    517       delete w1;
    518       w1 = w;
    519       w = NULL;
    520     }
    521   }
     550    }
     551  }
     552/*--- end of the main loop --------------------------------------*/
     553/*--- deleting the temporare data structures --------------------*/
    522554  if ((syzIndex!=0) && (res[syzIndex]!=NULL) && (idIs0(res[syzIndex])))
    523555    idDelete(&res[syzIndex]);
    524   if (w1!=NULL) delete w1;
    525   //if ((maxlength!=-1) && (!minim))
    526   //{
    527   //  while (syzIndex<=maxlength)
    528   //  {
    529   //    res[syzIndex]=idInit(1,1);
    530   //    syzIndex++;
    531   //    if (syzIndex<=maxlength)
    532   //    {
    533   //      res[syzIndex]=idFreeModule(1);
    534   //      syzIndex++;
    535   //    }
    536   //  }
    537   //}
     556  if (w !=NULL) delete w;
     557
    538558  Kstd1_deg=Kstd1_OldDeg;
    539559  if (!oldDegBound)
    540560    test &= ~Sy_bit(OPT_DEGBOUND);
     561
     562  for (i=1; i<=syzIndex; i++)
     563  {
     564    if (! idIs0(res[i]))
     565    {
     566      for (j=0; j<IDELEMS(res[i]); j++)
     567      {
     568        pShift(&res[i]->m[j], -rGetMaxSyzComp(i));
     569      }
     570    }
     571  }
     572/*--- going back to the original ring -------------------------*/
     573  if (origR != syz_ring)
     574  {
     575    rChangeCurrRing(origR, TRUE);
     576    for (i=0; i<=syzIndex; i++)
     577    {
     578      res[i] = idrMoveR_NoSort(res[i], syz_ring);
     579    }
     580  }
    541581  return res;
    542582}
     
    574614}
    575615
     616static poly sypCopyConstant(poly inp)
     617{
     618  poly outp=NULL,q;
     619
     620  while (inp!=NULL)
     621  {
     622    if (pIsConstantComp(inp))
     623    {
     624      if (outp==NULL)
     625      {
     626        q = outp = pHead(inp);
     627      }
     628      else
     629      {
     630        pNext(q) = pHead(inp);
     631        pIter(q);
     632      }
     633    }
     634    pIter(inp);
     635  }
     636  return outp;
     637}
    576638int syDetect(ideal id,int index,BOOLEAN homog,int * degrees,int * tocancel)
    577639{
     
    584646  for (i=0;i<IDELEMS(id);i++)
    585647  {
    586     p = id->m[i];
    587     while (p!=NULL)
    588     {
    589       if (pIsConstantComp(p))
    590       {
    591         if (temp->m[i]==NULL)
    592         {
    593           temp->m[i] = pHead(p);
    594           q = temp->m[i];
    595         }
    596         else
    597         {
    598           pNext(q) = pHead(p);
    599           pIter(q);
    600         }
    601       }
    602       pIter(p);
    603     }
     648    temp->m[i] = sypCopyConstant(id->m[i]);
    604649  }
    605650  i = IDELEMS(id);
     
    611656  }
    612657  j = 0;
     658  p = NULL;
    613659  while ((j<i) && (temp->m[j]==NULL)) j++;
    614   if (j<i)
    615   {
    616     p = temp->m[j];
    617     temp->m[j] = NULL;
    618   }
    619   else
    620   {
    621     p = NULL;
    622   }
    623   while (p!=NULL)
     660  while (j<i)
    624661  {
    625662    if (homog)
     
    633670      tocancel[0]--;
    634671    }
    635     ModComp = pGetComp(p);
    636 //Print("Element %d: ",j);pWrite(p);
    637     //Unit1 = pTakeOutComp1(&p,ModComp);
    638     pTakeOutComp(&p,ModComp, &Unit1, &lu);
    639     pSetComp(Unit1,0);
    640     for (k=j+1;k<i;k++)
    641     {
    642       if (temp->m[k]!=NULL)
    643       {
    644 //Print("erst %d: ",k);pWrite(temp->m[k]);
    645         //Unit2 = pTakeOutComp1(&(temp->m[k]),ModComp);
    646         pTakeOutComp(&(temp->m[k]),ModComp,&Unit2,&lu);
    647         if (Unit2!=NULL)
    648         {
    649           number tmp=nCopy(pGetCoeff(Unit2));
    650           tmp=nNeg(tmp);
    651           qq = pCopy(p);
    652           pMultN(qq,tmp);
    653           nDelete(&tmp);
    654           pMultN(temp->m[k],pGetCoeff(Unit1));
    655           temp->m[k] = pAdd(temp->m[k],qq);
    656 //Print("dann %d: ",k);pWrite(temp->m[k]);
    657           pDelete(&Unit2);
    658         }
    659       }
    660     }
    661 //PrintLn();
    662     pDelete(&Unit1);
    663     pDelete(&p);
     672    syGaussForOne(temp,j,pGetComp(temp->m[j]),j+1,i);
    664673    j++;
    665674    while ((j<i) && (temp->m[j]==NULL)) j++;
    666     if (j>=i)
    667     {
    668       idDelete(&temp);
    669       return  subFromRank;
    670     }
    671     p = temp->m[j];
    672     temp->m[j] = NULL;
    673675  }
    674676  idDelete(&temp);
Note: See TracChangeset for help on using the changeset viewer.