Changeset e960943 in git


Ignore:
Timestamp:
Oct 14, 1999, 2:50:29 PM (25 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b7b08cbfc7838d9595098d9d8994e6a44848ba40
Parents:
9a384e219388c1607b367164a5297b9e011b6589
Message:
* hannes: first step for avoiding syzcomp


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

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r9a384e re960943  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.108 1999-09-29 10:59:28 obachman Exp $ */
     4/* $Id: extra.cc,v 1.109 1999-10-14 12:50:25 Singular Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    488488      int j;
    489489      PrintS("varoffset:\n");
     490      #ifdef HAVE_SHIFTED_EXPONENTS
     491      for(j=0;j<=r->N;j++) Print("  v%d at pos %d, bit %d\n",
     492         j,r->VarOffset[j] & 0xffffff, r->VarOffset[j] >>24);
     493      Print("bitmask=%x\n",r->bitmask);
     494      #else
    490495      for(j=0;j<=r->N;j++) Print("  v%d at pos %d\n",j,r->VarOffset[j]);
     496      #endif
    491497      PrintS("ordsgn:\n");
    492498      for(j=0;j<r->pCompLSize;j++)
  • Singular/ideals.cc

    r9a384e re960943  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.56 1999-09-27 13:51:05 obachman Exp $ */
     4/* $Id: ideals.cc,v 1.57 1999-10-14 12:50:25 Singular Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    10761076  }
    10771077  temp = idInit(IDELEMS(first),1);
    1078   j = IDELEMS(temp);
     1078  j = IDELEMS(first);
     1079
     1080  ring orig_ring=currRing;
     1081  ring syz_ring=rAddSyzComp(currRing);
     1082  pSetSyzComp(length);
     1083
    10791084  while ((j>0) && (first->m[j-1]==NULL)) j--;
    10801085  k = 0;
     
    10831088    if (first->m[i]!=NULL)
    10841089    {
    1085       temp->m[k] = pCopy(first->m[i]);
     1090      if (syz_ring==orig_ring)
     1091        temp->m[k] = pCopy(first->m[i]);
     1092      else
     1093        temp->m[k] = pPermPoly(first->m[i],NULL,orig_ring,NULL,0);
    10861094      q = pOne();
    10871095      pSetComp(q,i+1+length);
     
    10991107    if (second->m[i]!=NULL)
    11001108    {
    1101       temp->m[k] = pCopy(second->m[i]);
     1109      if (syz_ring==orig_ring)
     1110        temp->m[k] = pCopy(second->m[i]);
     1111      else
     1112        temp->m[k] = pPermPoly(second->m[i],NULL,orig_ring,NULL,0);
    11021113      if (slength==0) pShift(&(temp->m[k]),1);
    11031114      k++;
    11041115    }
    11051116  }
    1106   pSetSyzComp(length);
    11071117  temp1 = kStd(temp,currQuotient,testHomog,&w,NULL,length);
    11081118  if (w!=NULL) delete w;
     1119  idDelete(&temp);
     1120
     1121  if(syz_ring!=orig_ring)
     1122    rChangeCurrRing(orig_ring,TRUE);
    11091123  pSetSyzComp(0);
    1110   idDelete(&temp);
     1124
    11111125  result = idInit(IDELEMS(temp1),rank);
    11121126  j = 0;
     
    11141128  {
    11151129    if ((temp1->m[i]!=NULL)
    1116     && (pGetComp(temp1->m[i])>length))
    1117     {
    1118       p = temp1->m[i];
    1119 //PrintS("die Syzygie ist: ");pWrite(p);
    1120       temp1->m[i] = NULL;
     1130    && (pRingGetComp(syz_ring,temp1->m[i])>length))
     1131    {
     1132      if(syz_ring==orig_ring)
     1133        p = pCopy(temp1->m[i]);
     1134      else
     1135        p = pPermPoly(temp1->m[i],NULL,syz_ring,NULL,0);
    11211136      while (p!=NULL)
    11221137      {
     
    11251140        k = pGetComp(p)-1-length;
    11261141        pSetComp(p,0);
    1127 //PrintS("das %d-te Element: ",k);pWrite(first->m[k]);
    11281142        result->m[j] = pAdd(result->m[j],pMult(pCopy(first->m[k]),p));
    11291143        p = q;
    11301144      }
    1131 //PrintS("Generator ist: ");pWrite(result->m[j]);
    11321145      j++;
    11331146    }
    11341147  }
     1148  if(syz_ring!=orig_ring)
     1149    rChangeCurrRing(syz_ring,FALSE);
     1150  idDelete(&temp1);
     1151  if(syz_ring!=orig_ring)
     1152    rChangeCurrRing(orig_ring,TRUE);
     1153  if(syz_ring!=orig_ring)
     1154    rKill(syz_ring);
     1155
    11351156  idSkipZeroes(result);
    11361157  return result;
     
    11741195  /* init -----------------------------------------------------------*/
    11751196  j += maxrk;
     1197  syzComp = k*maxrk;
     1198  ring orig_ring=currRing;
     1199  ring syz_ring=rAddSyzComp(currRing);
     1200  pSetSyzComp(syzComp);
     1201
    11761202  bigmat = idInit(j,(k+1)*maxrk);
    1177   syzComp = k*maxrk;
    1178   pSetSyzComp(syzComp);
    11791203  /* create unit matrices ------------------------------------------*/
    11801204  for (i=0;i<maxrk;i++)
     
    11991223        if (arg[j]->m[l]!=NULL)
    12001224        {
    1201           bigmat->m[i] = pCopy(arg[j]->m[l]);
     1225          if (syz_ring==orig_ring)
     1226            bigmat->m[i] = pCopy(arg[j]->m[l]);
     1227          else
     1228            bigmat->m[i] = pPermPoly(arg[j]->m[l],NULL,orig_ring,NULL,0);
    12021229          pShift(&(bigmat->m[i]),k*maxrk+isIdeal);
    12031230          i++;
     
    12111238  if (w!=NULL) delete w;
    12121239  idDelete(&bigmat);
     1240
     1241  if(syz_ring!=orig_ring)
     1242    rChangeCurrRing(orig_ring,TRUE);
    12131243  pSetSyzComp(0);
     1244
    12141245  /* interprete result ----------------------------------------*/
    12151246  result = idInit(8,maxrk);
     
    12171248  for (j=0;j<IDELEMS(tempstd);j++)
    12181249  {
    1219     if ((tempstd->m[j]!=NULL) && (pGetComp(tempstd->m[j])>syzComp))
     1250    if ((tempstd->m[j]!=NULL) && (pRingGetComp(syz_ring,tempstd->m[j])>syzComp))
    12201251    {
    12211252      if (k>=IDELEMS(result))
     
    12241255        IDELEMS(result) += 8;
    12251256      }
    1226       p = tempstd->m[j];
    1227       tempstd->m[j] = NULL;
     1257      if (syz_ring==orig_ring)
     1258        p = pCopy(tempstd->m[j]);
     1259      else
     1260        p = pPermPoly(tempstd->m[j],NULL,syz_ring,NULL,0);
    12281261      pShift(&p,-syzComp-isIdeal);
    12291262      result->m[k] = p;
     
    12321265  }
    12331266  /* clean up ----------------------------------------------------*/
     1267  if(syz_ring!=orig_ring)
     1268    rChangeCurrRing(syz_ring,FALSE);
    12341269  idDelete(&tempstd);
     1270  if(syz_ring!=orig_ring)
     1271  {
     1272    rChangeCurrRing(orig_ring,TRUE);
     1273    rKill(syz_ring);
     1274  }
    12351275  idSkipZeroes(result);
    12361276  return result;
     
    12571297*computes syzygies of h1,
    12581298*if quot != NULL it computes in the quotient ring modulo "quot"
    1259 */
    1260 ideal  idPrepare (ideal  h1,ideal  quot, tHomog h,
    1261   int* syzcomp, int *quotgen, int *quotdim, intvec **w)
     1299*works always in a ring with ringorder_s
     1300*/
     1301static ideal idPrepare (ideal  h1,ideal  quot, tHomog h,
     1302  int syzcomp, int *quotgen, int *quotdim, intvec **w)
    12621303{
    12631304  ideal   h2, h3;
     
    12651306  int     j,jj=0,k;
    12661307  poly    p,q;
    1267   BOOLEAN orderChanged=FALSE;
    12681308
    12691309  if (idIs0(h1)) return NULL;
    12701310  k = lengthFreeModule(h1);
    1271   if (*syzcomp<k) *syzcomp = k;
    1272   h2 = NULL;
    12731311  h2=idCopy(h1);
    12741312  i = IDELEMS(h2)-1;
    1275   //while ((i >= 0) && (h2->m[i] == NULL)) i--;
    12761313  if (k == 0)
    12771314  {
    12781315    for (j=0; j<=i; j++) pShift(&(h2->m[j]),1);
    1279     *syzcomp = 1;
    1280   }
    1281   h2->rank = *syzcomp+i+1;
     1316    k = 1;
     1317  }
     1318  if (syzcomp<k)
     1319  {
     1320    Warn("syzcomp too low, should be %d instead of %d",k,syzcomp);
     1321    syzcomp = k;
     1322    pSetSyzComp(k);
     1323  }
     1324  h2->rank = syzcomp+i+1;
    12821325  for (j=0; j<=i; j++)
    12831326  {
    12841327    p = h2->m[j];
    12851328    q = pOne();
    1286 #ifdef DRING
    1287     if (pDRING) { pdSetDFlag(q,1); pSetm(q); }
    1288 #endif
    1289     pSetComp(q,*syzcomp+1+j);
     1329    pSetComp(q,syzcomp+1+j);
    12901330    if (p!=NULL)
    12911331    {
     
    12961336      h2->m[j]=q;
    12971337  }
    1298   if (currRing->order[0]!=ringorder_c)
    1299   {
    1300     while ((currRing->order[jj]!=0) && (currRing->order[jj]!=ringorder_c)
    1301            && (currRing->order[jj]!=ringorder_C))
    1302     {
    1303       jj++;
    1304     }
    1305     if ((pOrdSgn==1) && (h==TRUE) && (*syzcomp==1) && (!pLexOrder)
    1306         && (currRing->order[jj]==ringorder_c))
    1307     {
    1308       for(j=0;(j<IDELEMS(h2) && (!orderChanged));j++)
    1309       {
    1310         if (h2->m[j] != NULL)
    1311         {
    1312           p=h2->m[j];
    1313           while ((p!=NULL)
    1314           && (pGetComp(p)<=*syzcomp))
    1315           {
    1316             if (pIsConstantComp(p))
    1317             {
    1318               pSetSyzComp(*syzcomp);
    1319               orderChanged=TRUE;
    1320               break;
    1321             }
    1322             pIter(p);
    1323           }
    1324         }
    1325       }
    1326     }
    1327     else
    1328     {
    1329       pSetSyzComp(*syzcomp);
    1330       orderChanged=TRUE;
    1331     }
    1332   }
    1333 
    1334 //  if (orderChanged) PrintS("order changed\n");
    1335 //  else PrintS("order not changed\n");
     1338
    13361339#ifdef PDEBUG
    13371340  for(j=0;j<IDELEMS(h2);j++) pTest(h2->m[j]);
    13381341#endif
    1339   h3=kStd(h2,quot,h,w,NULL,*syzcomp);
    1340   //h3->rank = h2->rank; done by kStd -> initBuchMora -> initS
    1341   //h3->rank-=*syzcomp;
     1342  h3=kStd(h2,quot,h,w,NULL,syzcomp);
    13421343  idDelete(&h2);
    1343   if (orderChanged) pSetSyzComp(0);
    13441344  return h3;
    13451345}
     
    13541354                  BOOLEAN setRegularity, int &deg)
    13551355{
    1356   ideal e, h3;
     1356  ideal e;
    13571357  poly  p;
    1358   int   i, j, k=0, quotdim, quotgen,length=0,reg;
     1358  int   i, j, k, quotdim, quotgen,length=0,reg;
    13591359  BOOLEAN isMonomial=TRUE;
    13601360
     
    13691369  if (idIs0(h1))
    13701370    return idFreeModule(IDELEMS(h1));
    1371   h3=idPrepare(h1,quot,h,&k,&quotgen,&quotdim,w);
    1372   if (h3==NULL)
     1371  k=max(0,idRankFreeModule(h1));
     1372
     1373  ring orig_ring=currRing;
     1374  ring syz_ring=rAddSyzComp(currRing);
     1375  pSetSyzComp(k);
     1376  ideal s_h1=idInit(IDELEMS(h1),h1->rank);
     1377  for(i=IDELEMS(h1)-1;i>=0;i--)
     1378  {
     1379    if(syz_ring==orig_ring)
     1380    {
     1381      s_h1->m[i]=pCopy(h1->m[i]);
     1382    }
     1383    else
     1384    {
     1385      s_h1->m[i]=pPermPoly(h1->m[i],NULL,orig_ring,NULL,0);
     1386    }
     1387  }
     1388  ideal s_quot=idInit(IDELEMS(quot),1);
     1389  for(i=IDELEMS(quot)-1;i>=0;i--)
     1390  {
     1391    if(syz_ring==orig_ring)
     1392    {
     1393      s_quot->m[i]=pCopy(quot->m[i]);
     1394    }
     1395    else
     1396    {
     1397      s_quot->m[i]=pPermPoly(quot->m[i],NULL,orig_ring,NULL,0);
     1398    }
     1399  }
     1400
     1401  ideal s_h3=idPrepare(s_h1,s_quot,h,k,&quotgen,&quotdim,w);
     1402  idDelete(&s_h1);
     1403  idDelete(&s_quot);
     1404
     1405  if (syz_ring!=orig_ring)
     1406    rChangeCurrRing(orig_ring,TRUE);
     1407  pSetSyzComp(0);
     1408
     1409  if (s_h3==NULL)
     1410  {
    13731411    return idFreeModule(IDELEMS(h1));
     1412  }
    13741413  i = -1;
    1375   e=idInit(16,h3->rank-k);
    1376   for (j=0; j<IDELEMS(h3); j++)
    1377   {
    1378     if (h3->m[j] != NULL)
    1379     {
    1380       if (pMinComp(h3->m[j]) > k)
    1381       {
    1382         p = h3->m[j];
    1383         h3->m[j]=NULL;
     1414  e=idInit(16,s_h3->rank-k);
     1415  for (j=0; j<IDELEMS(s_h3); j++)
     1416  {
     1417    if (s_h3->m[j] != NULL)
     1418    {
     1419      if (pMinComp(s_h3->m[j],syz_ring) > k)
     1420      {
     1421        if (syz_ring==orig_ring)
     1422        {
     1423          p=s_h3->m[j];
     1424          s_h3->m[j]=NULL;
     1425        }
     1426        else
     1427          p = pPermPoly(s_h3->m[j],NULL,syz_ring,NULL,0);
    13841428        pShift(&p,-k);
    13851429        if (p!=NULL)
     
    13961440      else
    13971441      {
    1398         isMonomial=isMonomial && (pNext(h3->m[j])==NULL);
    1399         pDelete(&pNext(h3->m[j]));
    1400       }
    1401     }
    1402   }
    1403   if ((!isMonomial) && (!TEST_OPT_NOTREGULARITY) && (setRegularity) && (h==isHomog))
    1404   {
    1405     idSkipZeroes(h3);
     1442        isMonomial=isMonomial && (pNext(s_h3->m[j])==NULL);
     1443        if(syz_ring!=orig_ring)
     1444        {
     1445          rChangeCurrRing(syz_ring,FALSE);
     1446          pDelete(&pNext(s_h3->m[j]));
     1447          rChangeCurrRing(orig_ring,TRUE);
     1448        }
     1449        else
     1450          pDelete(&pNext(s_h3->m[j]));
     1451      }
     1452    }
     1453  }
     1454  if ((!isMonomial)
     1455  && (!TEST_OPT_NOTREGULARITY)
     1456  && (setRegularity)
     1457  && (h==isHomog))
     1458  {
     1459    idSkipZeroes(s_h3); // works ring independend
     1460    ideal h3;
     1461    if (syz_ring==orig_ring)
     1462      h3=idCopy(s_h3);
     1463    else
     1464    {
     1465      h3=idInit(IDELEMS(s_h3),s_h3->rank);
     1466      for(i=IDELEMS(quot)-1;i>=0;i--)
     1467      {
     1468        h3->m[i]=pPermPoly(s_h3->m[i],NULL,syz_ring,NULL,0);
     1469      }
     1470    }
    14061471    resolvente res = sySchreyerResolvente(h3,-1,&length,TRUE);
    14071472    intvec * dummy = syBetti(res,length,&reg, *w);
     
    14131478    }
    14141479    Free((ADDRESS)res,length*sizeof(ideal));
    1415   }
    1416   idDelete(&h3);
     1480    idDelete(&h3);
     1481  }
     1482  if (syz_ring!=orig_ring)
     1483  {
     1484    rChangeCurrRing(syz_ring,FALSE);
     1485    idDelete(&s_h3);
     1486    rChangeCurrRing(orig_ring,TRUE);
     1487    rKill(syz_ring);
     1488  }
     1489  else
     1490    idDelete(&s_h3);
    14171491  idSkipZeroes(e);
    14181492  return e;
     
    14261500                  BOOLEAN setRegularity, int &deg)
    14271501{
    1428   ideal e, h3;
    14291502  poly  p;
    14301503  intvec * reord;
    1431   int   i, l=0, j, k=0, quotdim, quotgen,length=0,reg;
     1504  int   i, l=0, j, k, quotdim, quotgen,length=0,reg;
    14321505  BOOLEAN isMonomial=TRUE;
    14331506
    14341507  if (idIs0(h1))
    14351508    return idFreeModule(1);
    1436 //PrintS("h1 vorher\n");
    1437 //for (i=0;i<IDELEMS(h1);i++)
    1438 //{
    1439 //Print("Element %d: ",i);pWrite(h1->m[i]);
    1440 //}
    14411509  idSkipZeroes(h1);
    1442   h3=idPrepare(h1,quot,h,&k,&quotgen,&quotdim,w);
    1443 //PrintS("h1 nachher\n");
    1444 //for (i=0;i<IDELEMS(h3);i++)
    1445 //{
    1446 //Print("Element %d: ",i);pWrite(h3->m[i]);
    1447 //}
    1448   if (h3==NULL)
     1510
     1511  ring orig_ring=currRing;
     1512  ring syz_ring=rAddSyzComp(currRing);
     1513  pSetSyzComp(k);
     1514
     1515  ideal s_h1=idInit(IDELEMS(h1),h1->rank);
     1516  for(i=IDELEMS(h1)-1;i>=0;i--)
     1517  {
     1518    if(syz_ring==orig_ring)
     1519    {
     1520      s_h1->m[i]=pCopy(h1->m[i]);
     1521    }
     1522    else
     1523    {
     1524      s_h1->m[i]=pPermPoly(h1->m[i],NULL,orig_ring,NULL,0);
     1525    }
     1526  }
     1527  ideal s_quot=idInit(IDELEMS(quot),1);
     1528  for(i=IDELEMS(quot)-1;i>=0;i--)
     1529  {
     1530    if(syz_ring==orig_ring)
     1531    {
     1532      s_quot->m[i]=pCopy(quot->m[i]);
     1533    }
     1534    else
     1535    {
     1536      s_quot->m[i]=pPermPoly(quot->m[i],NULL,orig_ring,NULL,0);
     1537    }
     1538  }
     1539
     1540  ideal s_h3=idPrepare(s_h1,s_quot,h,k,&quotgen,&quotdim,w);
     1541  for (i=IDELEMS(s_h1);i!=0;i--)
     1542    pDelete(&(s_h1->m[i-1]));
     1543
     1544  if (s_h3==NULL)
     1545  {
     1546    idDelete(&s_h1);
     1547    idDelete(&s_quot);
     1548    if (syz_ring!=orig_ring)
     1549      rChangeCurrRing(orig_ring,TRUE);
     1550    pSetSyzComp(0);
     1551    for (i=IDELEMS(h1);i!=0;i--)
     1552      pDelete(&(h1->m[i-1]));
    14491553    return idFreeModule(1);
    1450   for (i=IDELEMS(h1);i!=0;i--)
    1451     pDelete(&(h1->m[i-1]));
     1554  }
     1555
    14521556  reord = new intvec(IDELEMS(h1)+1);
    14531557  i = -1;
    1454   e=idInit(16,h3->rank);
    1455   for (j=0; j<IDELEMS(h3); j++)
    1456   {
    1457     if (h3->m[j] != NULL)
    1458     {
    1459       p = h3->m[j];
     1558  ideal e=idInit(16,s_h3->rank);
     1559  for (j=0; j<IDELEMS(s_h3); j++)
     1560  {
     1561    if (s_h3->m[j] != NULL)
     1562    {
     1563      p = s_h3->m[j];
    14601564      if (pGetComp(p) > k)
    14611565      {
    1462         h3->m[j]=NULL;
     1566        s_h3->m[j]=NULL;
    14631567        pShift(&p,-k);
    14641568        if (p!=NULL)
     
    14751579      else
    14761580      {
    1477         while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k)) pIter(p);
     1581        while ((pNext(p)!=NULL) && (pGetComp(pNext(p))<=k))
     1582          pIter(p);
    14781583        if (pIsConstantComp(pNext(p)))
    14791584        {
    14801585          (*reord)[pGetComp(pNext(p))-k] = l+1;
    1481 //Print("Element %d mit Comp %d: ",j,pGetComp(pNext(p))-k);
    1482 //pWrite(h3->m[j]);
    1483           h1->m[l] = h3->m[j];
    1484           h3->m[j] = pCopy(h1->m[l]);
     1586          s_h1->m[l] = s_h3->m[j];
     1587          s_h3->m[j] = pCopy(s_h1->m[l]);
    14851588          pDelete(&pNext(p));
    14861589          l++;
    14871590        }
    1488         isMonomial=isMonomial && (pGetComp(pNext(h3->m[j]))>k);
    1489         pDelete(&pNext(h3->m[j]));
    1490       }
    1491     }
    1492   }
    1493   if ((!isMonomial) && (!TEST_OPT_NOTREGULARITY) && (setRegularity) && (h==isHomog))
    1494   {
    1495     idSkipZeroes(h3);
    1496     resolvente res = sySchreyerResolvente(h3,0,&length);
     1591        isMonomial=isMonomial && (pGetComp(pNext(s_h3->m[j]))>k);
     1592        pDelete(&pNext(s_h3->m[j]));
     1593      }
     1594    }
     1595  }
     1596  if ((!isMonomial)
     1597  && (!TEST_OPT_NOTREGULARITY)
     1598  && (setRegularity)
     1599  && (h==isHomog))
     1600  {
     1601    idSkipZeroes(s_h3);
     1602    resolvente res;
     1603    if (syz_ring==orig_ring)
     1604      res = sySchreyerResolvente(s_h3,0,&length);
     1605    else
     1606    {
     1607      rChangeCurrRing(orig_ring,TRUE);
     1608      ideal h3=idInit(IDELEMS(s_h3),s_h3->rank);
     1609      for(j=IDELEMS(s_h3)-1;j>=0;j--)
     1610      {
     1611        h3->m[j]=pPermPoly(s_h3->m[j],NULL,syz_ring,NULL,0);
     1612      }
     1613      res = sySchreyerResolvente(h3,0,&length);
     1614      idDelete(&h3);
     1615      rChangeCurrRing(syz_ring,FALSE);
     1616      idDelete(&s_h3);
     1617      rChangeCurrRing(orig_ring,TRUE);
     1618    }
    14971619    intvec * dummy = syBetti(res,length,&reg, *w);
    14981620    deg = reg+2;
     
    15031625    }
    15041626    Free((ADDRESS)res,length*sizeof(ideal));
    1505   }
    1506   idDelete(&h3);
    1507 //PrintS("Komponententransformation: ");
    1508 //reord->show();
    1509 //PrintLn();
    1510   for (i=IDELEMS(e);i!=0;i--)
    1511   {
    1512     if (e->m[i-1]!=NULL)
    1513     {
    1514       p = e->m[i-1];
     1627    if(syz_ring!=orig_ring)
     1628      rChangeCurrRing(syz_ring,TRUE);
     1629  }
     1630  else
     1631  {
     1632    idDelete(&s_h3);
     1633  }
     1634  ideal ee;
     1635  if(syz_ring!=orig_ring)
     1636  {
     1637    rChangeCurrRing(orig_ring,TRUE);
     1638    ee=idInit(IDELEMS(e),e->rank);
     1639    for(j=IDELEMS(e)-1;j>=0;j--)
     1640    {
     1641      ee->m[j]=pPermPoly(e->m[j],NULL,syz_ring,NULL,0);
     1642    }
     1643    rChangeCurrRing(syz_ring,FALSE);
     1644    idDelete(&e);
     1645    rChangeCurrRing(orig_ring,TRUE);
     1646  }
     1647  else
     1648  {
     1649    ee=e;
     1650    e=NULL;
     1651  }
     1652
     1653  for (i=IDELEMS(ee);i!=0;i--)
     1654  {
     1655    if (ee->m[i-1]!=NULL)
     1656    {
     1657      p = ee->m[i-1];
    15151658      while (p!=NULL)
    15161659      {
     
    15191662        pIter(p);
    15201663      }
    1521       e->m[i-1] = pOrdPolyMerge(e->m[i-1]);
    1522     }
    1523   }
    1524   idSkipZeroes(e);
     1664      ee->m[i-1] = pOrdPolyMerge(ee->m[i-1]);
     1665    }
     1666  }
     1667  idSkipZeroes(ee);
    15251668  delete reord;
    1526   return e;
     1669
     1670  return ee;
    15271671}
    15281672
     
    15331677ideal idLiftStd (ideal  h1,ideal  quot, matrix* ma, tHomog h)
    15341678{
    1535   int   i, j, k=0, t, quotgen, inputIsIdeal=lengthFreeModule(h1);
     1679  int   i, j, k, t, quotgen, inputIsIdeal=lengthFreeModule(h1);
    15361680  ideal e, h3;
    15371681  poly  p=NULL, q, qq;
     
    15421686  if (idIs0(h1))
    15431687    return idInit(1,h1->rank);
     1688  k=max(0,idRankFreeModule(h1));
     1689  //RING AENDERN(pSetSyzComp(k))
    15441690  h3=idPrepare(h1,quot,h,&k,&quotgen,&i,&w);
     1691  //RING AENDERN(pSetSyzComp)
    15451692  if (w!=NULL) delete w;
    15461693  i = 0;
     
    15791726      }
    15801727      if (!inputIsIdeal) pShift(&qq,-1);
    1581       //if (quotgen != 0)
    1582       //{
    1583       //  q = kNF(quot,qq);
    1584       //  pDelete(&qq);
    1585       //}
    1586       //else
    1587         q = qq;
     1728      q = qq;
    15881729      if (q !=NULL)
    15891730      {
     
    16171758  if  ((idRankFreeModule(mod)!=0) && (lsmod==0)) lsmod=1;
    16181759  k=lsmod;
    1619   //idSkipZeroes(mod);
    1620   h3=idPrepare(mod,currQuotient,(tHomog)FALSE,&k,&quotgen,&i,NULL);
     1760  //RING AENDERN(pSetSyzComp(k))
     1761  h3=idPrepare(mod,currQuotient,(tHomog)FALSE,k,&quotgen,&i,NULL);
     1762  //RING AENDERN(pSetSyzComp)
     1763  pSetSyzComp(k);
    16211764  if (!goodShape)
    16221765  {
     
    16411784    temp = submod;
    16421785  }
    1643   pSetSyzComp(k);
    16441786  result = kNF(h3,currQuotient,temp,k);
    16451787  result->rank = h3->rank;
  • Singular/polys.cc

    r9a384e re960943  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys.cc,v 1.44 1999-10-01 16:24:39 obachman Exp $ */
     4/* $Id: polys.cc,v 1.45 1999-10-14 12:50:26 Singular Exp $ */
    55
    66/*
     
    138138          break;
    139139        }
     140        case ro_syz:
     141        {
     142          int c=pGetComp(p);
     143          p->exp.l[o->data.syz.place]= (o->data.syz.limit > c);
     144          break;
     145        }
    140146        default:
    141147          Print("wrong ord in rSetm:%d\n",o->ord_typ);
     
    387393}
    388394
    389 /*2
    390 *the pComp0 for normal syzygies
    391 *compares monomials in the usual ring order (pCompOld)
    392 *but groups module indecees according indexBounds befor
    393 */
    394 static int mcompSyz(poly p1,poly p2)
    395 {
    396   if (pGetComp(p1)<=pMaxBound)
    397   {
    398     if (pGetComp(p2)>pMaxBound) return 1;
    399   }
    400   else if (pGetComp(p2)<=pMaxBound)
    401   {
    402     return -1;
    403   }
    404   return pCompOld(p1,p2);
    405 }
    406 
    407395void pSetSyzComp(int k)
    408396{
    409   if (k!=0)
    410   {
    411     if (pMaxBound==0)
    412     {
    413       pCompOld = pComp0;
    414       pComp0 = mcompSyz;
    415     }
    416     pMaxBound = k;
    417   }
    418   else
    419   {
    420     if (pMaxBound!=0)
    421     {
    422       pComp0 = pCompOld;
    423       pMaxBound = 0;
    424     }
     397  pMaxBound=k;
     398  if(currRing->typ[0].ord_typ==ro_syz)
     399  {
     400    currRing->typ[0].data.syz.limit=k;
     401  }
     402  else if (k!=0)
     403  {
     404    Warn("syzcomp in incompatible ring");
    425405  }
    426406}
  • Singular/polys.h

    r9a384e re960943  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: polys.h,v 1.24 1999-09-29 10:59:37 obachman Exp $ */
     6/* $Id: polys.h,v 1.25 1999-10-14 12:50:27 Singular Exp $ */
    77/*
    88* ABSTRACT - all basic methods to manipulate polynomials
     
    245245int       pLength(poly a);
    246246int       pMaxComp(poly p);
    247 int       pMinComp(poly p);
     247int       pMinComp(poly p, ring r=currRing);
    248248BOOLEAN   pOneComp(poly p);
    249249int       pWeight(int c);
  • Singular/polys1.cc

    r9a384e re960943  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: polys1.cc,v 1.29 1999-09-29 10:59:38 obachman Exp $ */
     4/* $Id: polys1.cc,v 1.30 1999-10-14 12:50:27 Singular Exp $ */
    55
    66/*
     
    646646* returns minimal column number in the modul element a (or 0)
    647647*/
    648 int pMinComp(poly p)
     648int pMinComp(poly p, ring r)
    649649{
    650650  int result,i;
    651651
    652652  if(p==NULL) return 0;
    653   result = pGetComp(p);
     653  result = pRingGetComp(r,p);
    654654  while (pNext(p)!=NULL)
    655655  {
    656656    pIter(p);
    657     i = pGetComp(p);
     657    i = pRingGetComp(r,p);
    658658    if (i<result) result = i;
    659659  }
  • Singular/ring.cc

    r9a384e re960943  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.68 1999-09-29 17:20:14 Singular Exp $ */
     4/* $Id: ring.cc,v 1.69 1999-10-14 12:50:28 Singular Exp $ */
    55
    66/*
     
    2727#include "ring.h"
    2828
    29 // static procedures
     29static const char * const ringorder_name[] =
     30{
     31  " ?", //ringorder_no = 0,
     32  "a", //ringorder_a,
     33  "c", //ringorder_c,
     34  "C", //ringorder_C,
     35  "M", //ringorder_M,
     36  "S", //ringorder_S,
     37  "s", //ringorder_s,
     38  "lp", //ringorder_lp,
     39  "dp", //ringorder_dp,
     40  "Dp", //ringorder_Dp,
     41  "wp", //ringorder_wp,
     42  "Wp", //ringorder_Wp,
     43  "ls", //ringorder_ls,
     44  "ds", //ringorder_ds,
     45  "Ds", //ringorder_Ds,
     46  "ws", //ringorder_ws,
     47  "Ws", //ringorder_Ws,
     48  #ifdef HAVE_SHIFTED_EXPONENTS
     49  "L", //ringorder_L,
     50  #endif
     51  " _" //ringorder_unspec
     52};
     53
     54static inline const char * rSimpleOrdStr(int ord)
     55{
     56  return ringorder_name[ord];
     57}
     58
    3059// unconditionally deletes fields in r
    3160static void rDelete(ring r);
     
    262291    intvec *iv = (intvec *)(sl->data);
    263292    if (((*iv)[1]==ringorder_c)||((*iv)[1]==ringorder_C)) i++;
     293    #ifdef HAVE_SHIFTED_EXPONENTS
     294    else if ((*iv)[1]==ringorder_L)
     295    {
     296      R->bitmask=(*iv)[2];
     297      n--;
     298    }
     299    #endif
    264300    else if ((*iv)[1]!=ringorder_a) o++;
    265     #ifdef HAVE_SHIFTED_EXPONENTS
    266     else if ((*iv)[1]!=ringorder_L)
    267     {
    268       R->bitmask=(*iv)[2];
    269     }
    270     else
    271     #endif
    272301    n++;
    273302    sl=sl->next;
     
    729758    Print("\n//        block %3d : ",l+1);
    730759
    731     Print("ordering %c", (" acCMSldDwWldDwWu")[r->order[l]]);
    732     if (r->order[l]>=ringorder_lp)
    733     {
    734       if (r->order[l]>=ringorder_ls)
    735         PrintS("s");
    736       else
    737         PrintS("p");
    738     }
     760    Print("ordering %s", rSimpleOrdStr(r->order[l]));
    739761
    740762    if ((r->order[l] >= ringorder_lp)
     
    10461068int rOrderName(char * ordername)
    10471069{
    1048   int order=0;
    1049 
    1050   switch (*ordername)
    1051   {
    1052   case 'l':
    1053     if (*(ordername+1)=='p') order = ringorder_lp;
    1054     else if (*(ordername+1)=='s') order = ringorder_ls;
    1055     break;
    1056   case 'd':
    1057     if (*(ordername+1)=='p') order = ringorder_dp;
    1058     else if (*(ordername+1)=='s') order = ringorder_ds;
    1059     break;
    1060   case 'w':
    1061     if (*(ordername+1)=='p') order = ringorder_wp;
    1062     else if (*(ordername+1)=='s') order = ringorder_ws;
    1063     break;
    1064   case 'D':
    1065     if (*(ordername+1)=='p') order = ringorder_Dp;
    1066     else if (*(ordername+1)=='s') order = ringorder_Ds;
    1067     break;
    1068   case 'W':
    1069     if (*(ordername+1)=='p') order = ringorder_Wp;
    1070     else if (*(ordername+1)=='s') order = ringorder_Ws;
    1071     break;
    1072   case 'c': order = ringorder_c; break;
    1073   case 'C': order = ringorder_C; break;
    1074   case 'a': order = ringorder_a; break;
    1075   case 'S': order = ringorder_S; break;
    1076   case 'M': order = ringorder_M; break;
    1077 #ifdef HAVE_SHIFTED_EXPONENTS
    1078   case 'L': order = ringorder_L; break;
    1079 #endif
    1080   default: break;
     1070  int order=ringorder_unspec;
     1071  while (order!= 0)
     1072  {
     1073    if (strcmp(ordername,rSimpleOrdStr(order))==0)
     1074      break;
     1075    order--;
    10811076  }
    10821077  if (order==0) Werror("wrong ring order `%s`",ordername);
     
    10951090  for (l=0; ; l++)
    10961091  {
    1097     StringAppend("%c",(" acCMSldDwWldDwW")[r->order[l]]);
    1098     if (r->order[l]>=ringorder_lp)
    1099     {
    1100       if (r->order[l]>=ringorder_ls)
    1101         StringAppendS("s");
    1102       else
    1103         StringAppendS("p");
    1104     }
     1092    StringAppend((char *)rSimpleOrdStr(r->order[l]));
    11051093    if ((r->order[l] != ringorder_c) && (r->order[l] != ringorder_C))
    11061094    {
     
    20202008      }
    20212009    }
    2022     if ((r->VarOffset[i]<0) ||(r->VarOffset[i]>r->ExpESize-1))
    2023     {
    2024       Print("varoffset out of range for var %d: %d\n",i,r->VarOffset[i]);
     2010    int tmp;
     2011    #ifdef HAVE_SHIFTED_EXPONENTS
     2012      tmp=r->VarOffset[i] & 0xffffff;
     2013      #if SIZEOF_LONG == 8
     2014        if ((r->VarOffset[i] >> 24) >63)
     2015      #else
     2016        if ((r->VarOffset[i] >> 24) >31)
     2017      #endif
     2018          Print("bit_start out of range:%d\n",r->VarOffset[i] >> 24);
     2019    #else
     2020      tmp=r->VarOffset[i];
     2021    #endif
     2022    if ((tmp<0) ||(tmp>r->ExpESize-1))
     2023    {
     2024      Print("varoffset out of range for var %d: %d\n",i,tmp);
    20252025    }
    20262026  }
     
    20472047
    20482048#ifdef HAVE_SHIFTED_EXPONENTS
    2049 static void rO_Align(int &place, int &bit_place)
     2049static void rO_Align(int &place)
    20502050{
    20512051  // increment place to the next aligned one
    20522052  // (count as Exponent_t,align as longs)
    2053   if (place & ((sizeof(long)/sizeof(Exponent_t))-1))
    2054   {
    2055     place += ((sizeof(long)/sizeof(Exponent_t))-1);
    2056     place &= (~((sizeof(long)/sizeof(Exponent_t))-1));
    2057   }
    2058   bit_place=0;
    2059 }
    2060 #else
    2061 static void rO_Align(int &place)
    2062 {
    2063   // increment place to the next aligned one
    2064   // (count as Exponent_t,align as longs)
    2065   if (place & ((sizeof(long)/sizeof(Exponent_t))-1))
    2066   {
    2067     place += ((sizeof(long)/sizeof(Exponent_t))-1);
    2068     place &= (~((sizeof(long)/sizeof(Exponent_t))-1));
    2069   }
    2070 }
    2071 #endif
     2053  if (place & ((sizeof(long)*8)-1))
     2054  {
     2055    place += ((sizeof(long)*8)-1);
     2056    place &= (~((sizeof(long)*8)-1));
     2057  }
     2058}
    20722059
    20732060static void rO_TDegree(int &place, int start, int end,
    2074     long *o, sro_ord &ord_struct)
     2061    long *o, sro_ord &ord_struct, int bits)
    20752062{
    20762063  // degree (aligned) of variables v_start..v_end, ordsgn 1
     
    20792066  ord_struct.data.dp.start=start;
    20802067  ord_struct.data.dp.end=end;
    2081   ord_struct.data.dp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2068  ord_struct.data.dp.place=place/(sizeof(long)*8));
    20822069  o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
    20832070  place++;
     
    20932080  ord_struct.data.dp.start=start;
    20942081  ord_struct.data.dp.end=end;
    2095   ord_struct.data.dp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2082  ord_struct.data.dp.place=place/(sizeof(long)*8);
    20962083  o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
    20972084  place++;
     
    21072094  ord_struct.data.wp.start=start;
    21082095  ord_struct.data.wp.end=end;
    2109   ord_struct.data.wp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2096  ord_struct.data.wp.place=place/(sizeof(long)*8);
    21102097  ord_struct.data.wp.weights=weights;
    21112098  o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
     
    21222109  ord_struct.data.wp.start=start;
    21232110  ord_struct.data.wp.end=end;
    2124   ord_struct.data.wp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2111  ord_struct.data.wp.place=place/(sizeof(long)*8);
    21252112  ord_struct.data.wp.weights=weights;
    21262113  o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
     
    21292116}
    21302117
    2131 #ifdef HAVE_SHIFTED_EXPONENTS
    2132 static void rO_LexVars(int &place, int start, int end, int &prev_ord,
    2133     long *o,int *v, int bits)
     2118static void rO_LexVars(int &place, int start, int end,
     2119  int &prev_ord, long *o,int *v, int bits)
    21342120{
    21352121  // a block of variables v_start..v_end with lex order, ordsgn 1
    21362122  int k;
    21372123  int incr=1;
    2138   if(prev_ord==-1) rO_Align(place);
     2124  if(prev_ord!=1) rO_Align(place);
     2125  int e_place=place/ sizeof(Exponent_t);
     2126  int bit_place=place - (e_place*sizeof(Exponent_t));
    21392127  if (start>end)
    21402128  {
    21412129    incr=-1;
    21422130  }
    2143   int bit_start=0;
    21442131  for(k=start;;k+=incr)
    21452132  {
    2146     o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
    2147     v[k]=place | (bit_start << 24);
    2148     bit_start+=bits;
     2133    o[place/(sizeof(Exponent_t)*8)]=1;
     2134    v[k]=e_place | (bit_place << 24);
     2135    bit_place+=bits;
    21492136#if SIZEOF_LONG == 4
    2150     if (bit_start > 32-bits) { bit_start=0; place++; }
     2137    if (bit_place > 32-bits) { bit_place=0; e_place++; }
    21512138#else /* SIZEOF_LONG == 8 */
    2152     if (bit_start > 64-bits) { bit_start=0; place++; }
     2139    if (bit_place > 64-bits) { bit_place=0; e_place++; }
    21532140#endif
    21542141    if (k==end) break;
    21552142  }
    21562143  prev_ord=1;
    2157 }
    2158 
    2159 static void rO_LexVars_neg(int &place, int start, int end, int &prev_ord,
    2160     long *o,int *v, int bits)
     2144  place = e_place*sizeof(Exponent_t)+bit_place;
     2145}
     2146
     2147static void rO_LexVars_neg(int &place, int start, int end,
     2148  int &prev_ord, long *o,int *v, int bits)
    21612149{
    21622150  // a block of variables v_start..v_end with lex order, ordsgn -1
    21632151  int k;
    21642152  int incr=1;
    2165   if(prev_ord==1) rO_Align(place);
     2153  if(prev_ord!=-1) rO_Align(place);
     2154  int e_place=place/ sizeof(Exponent_t);
     2155  int bit_place=place - (e_place*sizeof(Exponent_t));
    21662156  if (start>end)
    21672157  {
    21682158    incr=-1;
    21692159  }
    2170   int bit_start=0;
    21712160  for(k=start;;k+=incr)
    21722161  {
    2173     o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
    2174     v[k]=place | (bit_start << 24);
     2162    o[place/(sizeof(Exponent_t)*8)]=-1;
     2163    v[k]=e_place | (bit_place << 24);
     2164    bit_place+=bits;
    21752165#if SIZEOF_LONG == 4
    2176     if (bit_start > 32-bits) { bit_start=0; place++; }
     2166    if (bit_place > 32-bits) { bit_place=0; e_place++; }
    21772167#else /* SIZEOF_LONG == 8 */
    2178     if (bit_start > 64-bits) { bit_start=0; place++; }
     2168    if (bit_place > 64-bits) { bit_place=0; e_place++; }
    21792169#endif
    21802170    if (k==end) break;
    21812171  }
    21822172  prev_ord=-1;
    2183 }
    2184 
    2185 #else
    2186 
    2187 static void rO_LexVars(int &place, int start, int end, int &prev_ord,
    2188     long *o,int *v)
    2189 {
    2190   // a block of variables v_start..v_end with lex order, ordsgn 1
    2191   int k;
    2192   int incr=1;
    2193   if(prev_ord==-1) rO_Align(place);
    2194   if (start>end)
    2195   {
    2196     incr=-1;
    2197   }
    2198   for(k=start;;k+=incr)
    2199   {
    2200     o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
    2201     v[k]=place;
    2202     place++;
    2203     if (k==end) break;
    2204   }
    2205   prev_ord=1;
    2206 }
    2207 
    2208 static void rO_LexVars_neg(int &place, int start, int end, int &prev_ord,
    2209     long *o,int *v)
    2210 {
    2211   // a block of variables v_start..v_end with lex order, ordsgn -1
    2212   int k;
    2213   int incr=1;
    2214   if(prev_ord==1) rO_Align(place);
    2215   if (start>end)
    2216   {
    2217     incr=-1;
    2218   }
    2219   for(k=start;;k+=incr)
    2220   {
    2221     o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
    2222     v[k]=place;
    2223     place++;
    2224     if (k==end) break;
    2225   }
    2226   prev_ord=-1;
    2227 }
    2228 
    2229 #endif
    2230 
    2231 #ifndef HAVE_SHIFTED_EXPONENTS
    2232 #ifdef LONG_MONOMS
    2233 static void rO_DupVars(int &place, int start, int end)
    2234 {
    2235   // a block of variables v_start..v_end to be duplicated (for pDivisibleBy):
    2236   place+=(end-start+1);
    2237 }
    2238 #endif
    2239 #endif
     2173  place = e_place*sizeof(Exponent_t)+bit_place;
     2174}
    22402175
    22412176static void rO_Syzcomp(int &place, int &prev_ord,
     
    22452180  rO_Align(place);
    22462181  ord_struct.ord_typ=ro_syzcomp;
    2247   ord_struct.data.syzcomp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2182  ord_struct.data.syzcomp.place=place/(sizeof(long)*8));
    22482183  ord_struct.data.syzcomp.Components=NULL;
    22492184  ord_struct.data.syzcomp.ShiftedComponents=NULL;
    2250   o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
     2185  o[place/(sizeof(long)*8)]=1;
    22512186  prev_ord=1;
    22522187  place++;
    2253   rO_Align(place);
    2254 }
    2255 
    2256 #ifdef HAVE_SHIFTED_EXPONENTS
     2188  rO_Align(place,bit_place);
     2189}
     2190
     2191static void rO_Syz(int &place, int &prev_ord,
     2192    long *o, sro_ord &ord_struct)
     2193{
     2194  // ordering is derived from component number
     2195  if (prev_ord!= -1) rO_Align(place);
     2196  if ((place & 7) ERROR;
     2197  ord_struct.ord_typ=ro_syz;
     2198  ord_struct.data.syz.place=place/(sizeof(Exponent_t)*8));
     2199  ord_struct.data.syz.limit=0;
     2200  o[place/(sizeof(Exponent_t)*8)]= -1;
     2201  prev_ord=-1;
     2202  place+=Exponent_t*8;
     2203}
     2204
    22572205BOOLEAN rComplete(ring r, int force)
    22582206{
     
    22612209  int n=rBlocks(r)-1;
    22622210  int i;
    2263   int j=0;
    2264   int prev_ordsgn=0;
    2265   long *tmp_ordsgn=(long *)Alloc0(2*(n+r->N)*sizeof(long)); // wil be used for ordsgn
    2266   int *v=(int *)Alloc((r->N+1)*sizeof(int)); // will be used for VarOffset
    2267   for(i=r->N; i>=0 ; i--)
    2268   {
    2269     v[i]=-1;
    2270   }
    2271   sro_ord *tmp_typ=(sro_ord *)Alloc0(2*(n+r->N)*sizeof(sro_ord));
    2272   int typ_i=0;
    22732211  int bits;
    2274   int bit_place=0;
    22752212  switch(r->bitmask)
    22762213  {
     2214     case 0:
    22772215#if SIZEOF_LONG == 8
     2216                      r->bitmask=0xffffffffffffffffL; /* NO break */
    22782217     case 0xffffffffffffffffL: bits=64; break; /* 64 bit longs only */
    22792218#endif
     2219                      r->bitmask=0xffffffff; /* NO break */
    22802220     case 0xffffffff: bits=32; break;
    22812221#if SIZEOF_LONG == 8
     
    23032243       return TRUE;
    23042244  }
     2245  long *tmp_ordsgn=(long *)Alloc0(2*(n+r->N)*sizeof(long)); // wil be used for ordsgn
     2246  int *v=(int *)Alloc((r->N+1)*sizeof(int)); // will be used for VarOffset
     2247  for(i=r->N; i>=0 ; i--)
     2248  {
     2249    v[i]=-1;
     2250  }
     2251  sro_ord *tmp_typ=(sro_ord *)Alloc0(2*(n+r->N)*sizeof(sro_ord));
     2252  int typ_i=0;
     2253  int bit_place=0;
     2254  int prev_ordsgn=0;
    23052255  r->pVarLowIndex=0;
    23062256
    23072257  // fill in v, tmp_typ, tmp_ordsgn, determine pVarLowIndex, typ_i (== ordSize)
     2258  int j=0;
     2259  int j_bits=0;
    23082260  for(i=0;i<n;i++)
    23092261  {
     
    23112263    {
    23122264      case ringorder_a:
    2313         rO_WDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
     2265        rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
    23142266                   r->wvhdl[i]);
    23152267        r->pVarLowIndex=j;
     
    23182270
    23192271      case ringorder_c:
    2320         rO_LexVars_neg(j, 0,0, prev_ordsgn,tmp_ordsgn,v,bits);
     2272        rO_LexVars_neg(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,bits);
    23212273        break;
    23222274
    23232275      case ringorder_C:
    2324         rO_LexVars(j, 0,0, prev_ordsgn,tmp_ordsgn,v,bits);
     2276        rO_LexVars(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,bits);
    23252277        break;
    23262278
     
    23312283          for(l=0;l<k;l++)
    23322284          {
    2333             rO_WDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
     2285            rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2286                       tmp_typ[typ_i],
    23342287                       r->wvhdl[i]+(r->block1[i]-r->block0[i]+1)*l);
    23352288            typ_i++;
     
    23402293
    23412294      case ringorder_lp:
    2342         rO_LexVars(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,
    2343                    bits);
     2295        rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
     2296                   tmp_ordsgn,v,bits);
    23442297        break;
    23452298
    23462299      case ringorder_ls:
    2347         rO_LexVars_neg(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,
    2348                        bits);
     2300        rO_LexVars_neg(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
     2301                       tmp_ordsgn,v, bits);
    23492302        break;
    23502303
     
    23522305        if (r->block0[i]==r->block1[i])
    23532306        {
    2354           rO_LexVars(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,
    2355                      bits);
     2307          rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
     2308                     tmp_ordsgn,v, bits);
    23562309        }
    23572310        else
    23582311        {
    2359           rO_TDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]);
     2312          rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2313                     tmp_typ[typ_i]);
    23602314          r->pVarLowIndex=j;
    23612315          typ_i++;
    2362           rO_LexVars_neg(j, r->block1[i],r->block0[i]+1,
     2316          rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1,
    23632317                         prev_ordsgn,tmp_ordsgn,v,bits);
    23642318        }
     
    23682322        if (r->block0[i]==r->block1[i])
    23692323        {
    2370           rO_LexVars(j, r->block0[i],r->block1[i], prev_ordsgn,tmp_ordsgn,v,
    2371                      bits);
     2324          rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
     2325                     tmp_ordsgn,v, bits);
    23722326        }
    23732327        else
    23742328        {
    2375           rO_TDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]);
     2329          rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2330                     tmp_typ[typ_i]);
    23762331          r->pVarLowIndex=j;
    23772332          typ_i++;
    2378           rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,
    2379                      bits);
     2333          rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn,
     2334                     tmp_ordsgn,v, bits);
    23802335        }
    23812336        break;
     
    23842339        if (r->block0[i]==r->block1[i])
    23852340        {
    2386           rO_LexVars_neg(j, r->block0[i],r->block1[i],prev_ordsgn,tmp_ordsgn,v,
    2387                          bits);
     2341          rO_LexVars_neg(j, j_bits,r->block0[i],r->block1[i],prev_ordsgn,
     2342                         tmp_ordsgn,v,bits);
    23882343        }
    23892344        else
    23902345        {
    2391           rO_TDegree_neg(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]);
     2346          rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2347                         tmp_typ[typ_i]);
    23922348          r->pVarLowIndex=j;
    23932349          typ_i++;
    2394           rO_LexVars_neg(j, r->block1[i],r->block0[i]+1,
     2350          rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1,
    23952351                         prev_ordsgn,tmp_ordsgn,v,bits);
    23962352        }
     
    24002356        if (r->block0[i]==r->block1[i])
    24012357        {
    2402           rO_LexVars_neg(j, r->block0[i],r->block1[i],prev_ordsgn,tmp_ordsgn,v,
    2403                          bits);
     2358          rO_LexVars_neg(j, j_bits, r->block0[i],r->block1[i],prev_ordsgn,
     2359                         tmp_ordsgn,v, bits);
    24042360        }
    24052361        else
    24062362        {
    2407           rO_TDegree_neg(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i]);
     2363          rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2364                         tmp_typ[typ_i]);
    24082365          r->pVarLowIndex=j;
    24092366          typ_i++;
    2410           rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,
    2411                      bits);
     2367          rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn,
     2368                     tmp_ordsgn,v, bits);
    24122369        }
    24132370        break;
    24142371
    24152372      case ringorder_wp:
    2416         rO_WDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
    2417                    r->wvhdl[i]);
     2373        rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2374                   tmp_typ[typ_i], r->wvhdl[i]);
    24182375        r->pVarLowIndex=j;
    24192376        typ_i++;
    24202377        if (r->block1[i]!=r->block0[i])
    2421           rO_LexVars_neg(j, r->block1[i],r->block0[i]+1, prev_ordsgn,tmp_ordsgn,
    2422                          v,bits);
     2378          rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn,
     2379                         tmp_ordsgn, v,bits);
    24232380        break;
    24242381
    24252382      case ringorder_Wp:
    2426         rO_WDegree(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
    2427                   r->wvhdl[i]);
     2383        rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2384                   tmp_typ[typ_i], r->wvhdl[i]);
    24282385        r->pVarLowIndex=j;
    24292386        typ_i++;
    24302387        if (r->block1[i]!=r->block0[i])
    2431           rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,
    2432                      bits);
     2388          rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn,
     2389                     tmp_ordsgn,v, bits);
    24332390        break;
    24342391
    24352392      case ringorder_ws:
    2436         rO_WDegree_neg(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
    2437                        r->wvhdl[i]);
     2393        rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2394                       tmp_typ[typ_i], r->wvhdl[i]);
    24382395        r->pVarLowIndex=j;
    24392396        typ_i++;
    24402397        if (r->block1[i]!=r->block0[i])
    2441           rO_LexVars_neg(j, r->block1[i],r->block0[i]+1, prev_ordsgn,tmp_ordsgn,
    2442                          v,bits);
     2398          rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn,
     2399                         tmp_ordsgn, v,bits);
    24432400        break;
    24442401
    24452402      case ringorder_Ws:
    2446         rO_WDegree_neg(j,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
    2447                        r->wvhdl[i]);
     2403        rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
     2404                       tmp_typ[typ_i], r->wvhdl[i]);
    24482405        r->pVarLowIndex=j;
    24492406        typ_i++;
    24502407        if (r->block1[i]!=r->block0[i])
    2451           rO_LexVars(j, r->block0[i],r->block1[i]-1, prev_ordsgn,tmp_ordsgn,v,
    2452                      bits);
     2408          rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn,
     2409                     tmp_ordsgn,v, bits);
    24532410        break;
    24542411
    24552412      case ringorder_S:
    2456         rO_Syzcomp(j, prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
     2413        rO_Syzcomp(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
     2414        r->pVarLowIndex=j;
     2415        typ_i++;
     2416        break;
     2417
     2418      case ringorder_s:
     2419        rO_Syz(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
    24572420        r->pVarLowIndex=j;
    24582421        typ_i++;
     
    24682431
    24692432  int j0=j-1;
    2470   rO_Align(j);
     2433  rO_Align(j,j_bits);
    24712434  r->pCompHighIndex=(j-1)/(sizeof(long)/sizeof(Exponent_t));
    24722435  j=j0+1;
     
    24792442      if (prev_ordsgn==1)
    24802443      {
    2481         rO_LexVars(j, i,i, prev_ordsgn,tmp_ordsgn,v,bits);
     2444        rO_LexVars(j, j_bits, i,i, prev_ordsgn,tmp_ordsgn,v,bits);
    24822445      }
    24832446      else
    24842447      {
    2485         rO_LexVars_neg(j, i,i, prev_ordsgn,tmp_ordsgn,v,bits);
     2448        rO_LexVars_neg(j,j_bits,i,i, prev_ordsgn,tmp_ordsgn,v,bits);
    24862449      }
    24872450    }
     
    24892452
    24902453  r->pVarHighIndex=j-1;
    2491   rO_Align(j);
     2454  rO_Align(j,j_bits);
    24922455  // ----------------------------
    24932456  // finished with constructing the monomial, computing sizes:
     
    25632526  for(j=r->N;j>=0;j--)
    25642527  {
    2565     r->VarOffset[j]=r->ExpESize-v[j]-1;
     2528    int tmp=v[j];
     2529    r->VarOffset[j] = r->ExpESize-(tmp & 0xffffff)-1;
     2530    r->VarOffset[j] |= (tmp & (~0xffffff));
    25662531  }
    25672532  Free((ADDRESS)v,(r->N+1)*sizeof(int));
     
    25862551  return FALSE;
    25872552}
    2588 #else
     2553#else /* not HAVE_SHIFTED_EXPONENTS: */
     2554static void rO_Align(int &place)
     2555{
     2556  // increment place to the next aligned one
     2557  // (count as Exponent_t,align as longs)
     2558  if (place & ((sizeof(long)/sizeof(Exponent_t))-1))
     2559  {
     2560    place += ((sizeof(long)/sizeof(Exponent_t))-1);
     2561    place &= (~((sizeof(long)/sizeof(Exponent_t))-1));
     2562  }
     2563}
     2564
     2565static void rO_TDegree(int &place, int start, int end,
     2566    long *o, sro_ord &ord_struct)
     2567{
     2568  // degree (aligned) of variables v_start..v_end, ordsgn 1
     2569  rO_Align(place);
     2570  ord_struct.ord_typ=ro_dp;
     2571  ord_struct.data.dp.start=start;
     2572  ord_struct.data.dp.end=end;
     2573  ord_struct.data.dp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2574  o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
     2575  place++;
     2576  rO_Align(place);
     2577}
     2578
     2579static void rO_TDegree_neg(int &place, int start, int end,
     2580    long *o, sro_ord &ord_struct)
     2581{
     2582  // degree (aligned) of variables v_start..v_end, ordsgn -1
     2583  rO_Align(place);
     2584  ord_struct.ord_typ=ro_dp;
     2585  ord_struct.data.dp.start=start;
     2586  ord_struct.data.dp.end=end;
     2587  ord_struct.data.dp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2588  o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
     2589  place++;
     2590  rO_Align(place);
     2591}
     2592
     2593static void rO_WDegree(int &place, int start, int end,
     2594    long *o, sro_ord &ord_struct, int *weights)
     2595{
     2596  // weighted degree (aligned) of variables v_start..v_end, ordsgn 1
     2597  rO_Align(place);
     2598  ord_struct.ord_typ=ro_wp;
     2599  ord_struct.data.wp.start=start;
     2600  ord_struct.data.wp.end=end;
     2601  ord_struct.data.wp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2602  ord_struct.data.wp.weights=weights;
     2603  o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
     2604  place++;
     2605  rO_Align(place);
     2606}
     2607
     2608static void rO_WDegree_neg(int &place, int start, int end,
     2609    long *o, sro_ord &ord_struct, int *weights)
     2610{
     2611  // weighted degree (aligned) of variables v_start..v_end, ordsgn -1
     2612  rO_Align(place);
     2613  ord_struct.ord_typ=ro_wp;
     2614  ord_struct.data.wp.start=start;
     2615  ord_struct.data.wp.end=end;
     2616  ord_struct.data.wp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2617  ord_struct.data.wp.weights=weights;
     2618  o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
     2619  place++;
     2620  rO_Align(place);
     2621}
     2622
     2623static void rO_LexVars(int &place, int start, int end, int &prev_ord,
     2624    long *o,int *v)
     2625{
     2626  // a block of variables v_start..v_end with lex order, ordsgn 1
     2627  int k;
     2628  int incr=1;
     2629  if(prev_ord!=1) rO_Align(place);
     2630  if (start>end)
     2631  {
     2632    incr=-1;
     2633  }
     2634  for(k=start;;k+=incr)
     2635  {
     2636    o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
     2637    v[k]=place;
     2638    place++;
     2639    if (k==end) break;
     2640  }
     2641  prev_ord=1;
     2642}
     2643
     2644static void rO_LexVars_neg(int &place, int start, int end, int &prev_ord,
     2645    long *o,int *v)
     2646{
     2647  // a block of variables v_start..v_end with lex order, ordsgn -1
     2648  int k;
     2649  int incr=1;
     2650  if(prev_ord!=-1) rO_Align(place);
     2651  if (start>end)
     2652  {
     2653    incr=-1;
     2654  }
     2655  for(k=start;;k+=incr)
     2656  {
     2657    o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
     2658    v[k]=place;
     2659    place++;
     2660    if (k==end) break;
     2661  }
     2662  prev_ord=-1;
     2663}
     2664
     2665#ifdef LONG_MONOMS
     2666static void rO_DupVars(int &place, int start, int end)
     2667{
     2668  // a block of variables v_start..v_end to be duplicated (for pDivisibleBy):
     2669  place+=(end-start+1);
     2670}
     2671#endif
     2672
     2673static void rO_Syzcomp(int &place, int &prev_ord,
     2674    long *o, sro_ord &ord_struct)
     2675{
     2676  // ordering is derived from component number
     2677  rO_Align(place);
     2678  ord_struct.ord_typ=ro_syzcomp;
     2679  ord_struct.data.syzcomp.place=place/(sizeof(long)/sizeof(Exponent_t));
     2680  ord_struct.data.syzcomp.Components=NULL;
     2681  ord_struct.data.syzcomp.ShiftedComponents=NULL;
     2682  o[place/(sizeof(long)/sizeof(Exponent_t))]=1;
     2683  prev_ord=1;
     2684  place++;
     2685  rO_Align(place);
     2686}
     2687
     2688static void rO_Syz(int &place, int &prev_ord,
     2689    long *o, sro_ord &ord_struct)
     2690{
     2691  // ordering is derived from component number
     2692  if(prev_ord!= -1) rO_Align(place);
     2693  ord_struct.ord_typ=ro_syz;
     2694  ord_struct.data.syz.place=place/(sizeof(long)/sizeof(Exponent_t));
     2695  ord_struct.data.syz.limit=0;
     2696  o[place/(sizeof(long)/sizeof(Exponent_t))]=-1;
     2697  prev_ord=-1;
     2698  place++;
     2699  rO_Align(place);
     2700}
     2701
    25892702BOOLEAN rComplete(ring r, int force)
    25902703{
     
    27432856      case ringorder_S:
    27442857        rO_Syzcomp(j, prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
     2858        r->pVarLowIndex=j;
     2859        typ_i++;
     2860        break;
     2861
     2862      case ringorder_s:
     2863        rO_Syz(j, prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
    27452864        r->pVarLowIndex=j;
    27462865        typ_i++;
     
    30173136  *currComponents =   r->typ[1].data.syzcomp.Components;
    30183137}
     3138
     3139ring rAddSyzComp(ring r)
     3140{
     3141  if (r->order[0]==ringorder_c)
     3142    return currRing;
     3143
     3144  ring res=rCopy(r);
     3145  if (res->qideal!=NULL)
     3146  {
     3147    idDelete(&(res->qideal));
     3148  }
     3149  rUnComplete(res);
     3150  int i=rBlocks(r);
     3151  Free((ADDRESS)res->order,i*sizeof(int));
     3152  res->order=(int *)Alloc((i+1)*sizeof(int));
     3153  memcpy(&(res->order[1]),&(r->order[0]),i*sizeof(int));
     3154  Free((ADDRESS)res->block0,i*sizeof(int));
     3155  res->block0=(int *)Alloc((i+1)*sizeof(int));
     3156  memcpy(&(res->block0[1]),&(r->block0[0]),i*sizeof(int));
     3157  Free((ADDRESS)res->block1,i*sizeof(int));
     3158  res->block1=(int *)Alloc((i+1)*sizeof(int));
     3159  memcpy(&(res->block1[1]),&(r->block1[0]),i*sizeof(int));
     3160  res->order[0]=ringorder_s;
     3161  rComplete(res);
     3162  rChangeCurrRing(res,TRUE);
     3163  if(r->qideal!=NULL)
     3164  {
     3165    res->qideal=idInit(IDELEMS(r->qideal),1);
     3166    for(i=IDELEMS(r->qideal)-1;i>=0;i--)
     3167    {
     3168      res->qideal->m[i]=pPermPoly(r->qideal->m[i],NULL,r,NULL,0);
     3169    }
     3170  }
     3171  return res;
     3172}
  • Singular/ring.h

    r9a384e re960943  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.35 1999-09-29 17:19:05 Singular Exp $ */
     9/* $Id: ring.h,v 1.36 1999-10-14 12:50:28 Singular Exp $ */
    1010
    1111/* includes */
     
    2626void   rKill(ring r);
    2727ring   rCopy(ring r);
     28ring   rAddSyzComp(ring r);
    2829
    2930#ifdef PDEBUG
     
    126127  ringorder_M,
    127128  ringorder_S,
     129  ringorder_s,
    128130  ringorder_lp,
    129131  ringorder_dp,
  • Singular/structs.h

    r9a384e re960943  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.26 1999-09-29 13:42:54 Singular Exp $ */
     6/* $Id: structs.h,v 1.27 1999-10-14 12:50:29 Singular Exp $ */
    77/*
    88* ABSTRACT
     
    124124  ro_cp, // ordering duplicates variables
    125125  ro_syzcomp, // ordering indicates "subset" of component number
     126  ro_syz, // ordering  with component number >syzcomp is lower
    126127  ro_none
    127128}
     
    168169typedef struct sro_syzcomp sro_syzcomp;
    169170
     171// ordering  with component number >syzcomp is lower
     172struct sro_syz
     173{
     174  short place;  // where the index is stored (in L)
     175  int limit;    // syzcomp
     176};
     177
     178typedef struct sro_syz sro_syz;
    170179
    171180struct sro_ord
     
    178187     sro_cp cp;
    179188     sro_syzcomp syzcomp;
     189     sro_syz syz;
    180190  } data;
    181191};
Note: See TracChangeset for help on using the changeset viewer.