Changeset 645a19 in git


Ignore:
Timestamp:
Jul 20, 2009, 2:01:13 PM (14 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ba3e3ef698fa0b7c5867199959cc83330073d3cb')
Children:
195b03db00f5e08ad6a891adcf3a7794a5dd00bf
Parents:
45c67dc7a3eec0097d1ad6ff5635d960cc089937
Message:
*motsak: deep kernel implementation of induced Schreyer ordering + helpers


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

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r45c67dc r645a19  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.307 2009-07-16 08:12:26 ederc Exp $ */
     4/* $Id: extra.cc,v 1.308 2009-07-20 12:01:13 motsak Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    8888#endif
    8989
     90#include "attrib.h"
     91
    9092#if defined(HPUX_10) || defined(HPUX_9)
    9193extern "C" int setenv(const char *name, const char *value, int overwrite);
     
    197199    leftv h=args->next;
    198200// ONLY documented system calls go here
    199 // Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM
     201// Undocumented system calls go down into jjEXTENDED_SYSTEM (#ifdef HAVE_EXTENDED_SYSTEM)
    200202/*==================== nblocks ==================================*/
    201203    if (strcmp(sys_cmd, "nblocks") == 0)
     
    725727
    726728
     729#if 0
     730    /// Returns old SyzCompLimit, can set new limit
     731    if(strcmp(sys_cmd,"SetSyzComp")==0)
     732    {
     733      res->rtyp = INT_CMD;
     734      res->data = (void *)rGetCurrSyzLimit(currRing);
     735      if ((h!=NULL) && (h->Typ()==INT_CMD))
     736      {
     737        const int iSyzComp = (int)((long)(h->Data()));
     738        assume( iSyzComp > 0 );
     739        rSetSyzComp( iSyzComp );
     740      }
     741
     742      return FALSE;
     743    }
     744    /// Endowe the current ring with additional (leading) Syz-component ordering
     745    if(strcmp(sys_cmd,"MakeSyzCompOrdering")==0)
     746    {
     747      extern ring rAssure_SyzComp(const ring r, BOOLEAN complete);
     748
     749//    res->data = rCurrRingAssure_SyzComp(); // changes current ring! :(
     750      res->data = (void *)rAssure_SyzComp(currRing, TRUE);
     751      res->rtyp = RING_CMD; // return new ring!
     752
     753      return FALSE;
     754    }
     755#endif
     756
     757    /// Same for Induced Schreyer ordering (ordering on components is defined by sign!)
     758    if(strcmp(sys_cmd,"MakeInducedSchreyerOrdering")==0)
     759    {
     760      extern ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete, int sign);
     761      int sign = 1;
     762      if ((h!=NULL) && (h->Typ()==INT_CMD))
     763      {
     764        sign = (int)((long)(h->Data()));
     765        assume( sign == 1 || sign == -1 );
     766      }
     767      res->data = (void *)rAssure_InducedSchreyerOrdering(currRing, TRUE, sign);
     768      res->rtyp = RING_CMD; // return new ring!
     769      return FALSE;
     770    }
     771
     772    /// Returns old SyzCompLimit, can set new limit
     773    if(strcmp(sys_cmd,"SetISReferrence")==0)
     774    {
     775      extern void rSetISReference(const ideal F, const int l, const int p, const intvec * componentWeights, const ring r);
     776
     777      if ((h!=NULL) && ( (h->Typ()==IDEAL_CMD) || (h->Typ()==MODUL_CMD)))
     778       {
     779        intvec * componentWeights = (intvec *)atGet(h,"isHomog",INTVEC_CMD); // No copy?!
     780        const ideal F = (ideal)h->Data(); ; // No copy!
     781        h=h->next;
     782
     783        int l = 0; // Starting syz-comp (1st: i+1)
     784
     785        if ((h!=NULL) && (h->Typ()==INT_CMD))
     786        {
     787          l = (int)((long)(h->Data())); h=h->next;
     788        }
     789
     790        int p = 0; // which IS-block? p^th!
     791
     792        if ((h!=NULL) && (h->Typ()==INT_CMD))
     793        {
     794          p = (int)((long)(h->Data())); h=h->next;
     795        }
     796
     797        // F & componentWeights belong to that ordering block of currRing now:
     798        rSetISReference(F, l, p, componentWeights, currRing); // F and componentWeights will be copied!
     799      }
     800      else
     801      {
     802        WerrorS("`system(\"SetISReferrence\",<ideal/module>, [int, int])` expected");
     803        return TRUE;
     804      }
     805      return FALSE;
     806    }
     807
     808
     809
     810////////////////////////////////////////////////////////////////////////
     811/// Additional interface functions to non-commutative subsystem (PLURAL)
     812///
     813
     814
    727815#ifdef HAVE_PLURAL
    728816/*==================== Approx_Step  =================*/
     
    19702058    }
    19712059    else
     2060/*==================== poly debug ==================================*/
     2061      if(strcmp(sys_cmd,"p")==0)
     2062      {
    19722063#ifdef RDEBUG
    1973 /*==================== poly debug ==================================*/
    1974     if(strcmp(sys_cmd,"p")==0)
    1975     {
    1976       pDebugPrint((poly)h->Data());
    1977       return FALSE;
    1978     }
    1979     else
     2064        pDebugPrint((poly)h->Data());
     2065#endif
     2066        return FALSE;
     2067      }
     2068      else
    19802069/*==================== ring debug ==================================*/
    1981     if(strcmp(sys_cmd,"r")==0)
    1982     {
    1983       rDebugPrint((ring)h->Data());
    1984       return FALSE;
    1985     }
    1986     else
    1987 #endif
     2070      if(strcmp(sys_cmd,"r")==0)
     2071      {
     2072#ifdef RDEBUG
     2073        rDebugPrint((ring)h->Data());
     2074#endif
     2075        return FALSE;
     2076      }
     2077/*==================== generic debug ==================================*/
     2078      if(strcmp(sys_cmd,"DebugPrint")==0)
     2079      {
     2080        if( h->Typ() == RING_CMD)
     2081        {
     2082          const ring r = (const ring)h->Data();
     2083          rWrite(r);
     2084          PrintLn();
     2085#ifdef RDEBUG
     2086          rDebugPrint(r);
     2087#endif
     2088        }
     2089        else
     2090        if( h->Typ() == POLY_CMD || h->Typ() == VECTOR_CMD)
     2091        {
     2092          const int nTerms = 3;
     2093          const poly p = (const poly)h->Data();
     2094          p_DebugPrint(p, currRing, currRing, nTerms);
     2095        }
     2096        else
     2097        if( h->Typ() == IDEAL_CMD || h->Typ() == MODUL_CMD)
     2098        {
     2099          const int nTerms = 3;
     2100          const ideal id = (const ideal)h->Data();
     2101          idShow(id, currRing, currRing, nTerms);
     2102        }
     2103
     2104        return FALSE;
     2105      } else
    19882106/*==================== mtrack ==================================*/
    19892107    if(strcmp(sys_cmd,"mtrack")==0)
     
    25892707      {
    25902708        WerrorS("ideal expected");
    2591         return false;
     2709        return TRUE;
    25922710      }
    25932711     
     
    26042722      res->rtyp=IDEAL_CMD;
    26052723      res->data=(ideal) F5main(G,r,opt);
    2606       return false;
     2724      return FALSE;
    26072725    }
    26082726    else
     
    26152733      {
    26162734        WerrorS("ideal expected");
    2617         return false;
     2735        return TRUE;
    26182736      }
    26192737     
     
    26222740      res->rtyp=IDEAL_CMD;
    26232741      res->data=(ideal) f5cMain(G,r);
    2624       return false;
     2742      return FALSE;
    26252743    }
    26262744    else
  • kernel/ideals.cc

    r45c67dc r645a19  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.74 2009-06-04 08:14:57 Singular Exp $ */
     4/* $Id: ideals.cc,v 1.75 2009-07-20 12:00:50 motsak Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    99/* includes */
    1010#include "mod2.h"
     11
     12#ifndef NDEBUG
     13# define MYTEST 0
     14#else /* ifndef NDEBUG */
     15# define MYTEST 0
     16#endif /* ifndef NDEBUG */
     17
    1118#include "structs.h"
    1219#include "omalloc.h"
     
    2633
    2734
    28 #define MYTEST 0
    2935
    3036
     
    6672//#ifndef __OPTIMIZE__
    6773// this is mainly for outputting an ideal within the debugger
    68 void idShow(ideal id)
    69 {
     74void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
     75{
     76  assume( debugPrint >= 0 );
     77 
    7078  if( id == NULL )
    7179    Print("(NULL)");
     
    7381  {
    7482    Print("Module of rank %ld,real rank %ld and %d generators.\n",
    75            id->rank,idRankFreeModule(id),IDELEMS(id));
    76     for (int i=0;i<id->ncols*id->nrows;i++)
    77     {
    78       if (id->m[i]!=NULL)
    79       {
    80         Print("generator %d: ",i);pWrite(id->m[i]);
    81       }
     83          id->rank,idRankFreeModule(id, lmRing, tailRing),IDELEMS(id));
     84
     85    int j = (id->ncols*id->nrows) - 1;
     86    while ((j > 0) && (id->m[j]==NULL)) j--;
     87    for (int i = 0; i <= j; i++)
     88    {
     89      Print("generator %d: ",i); p_DebugPrint(id->m[i], lmRing, tailRing, debugPrint);
    8290    }
    8391  }
     
    13231331  Print("Prepare::h2: ");
    13241332  idPrint(h2);
     1333
     1334  for(j=0;j<IDELEMS(h2);j++) pTest(h2->m[j]);
     1335
    13251336#endif
    13261337#endif
     
    13561367#endif
    13571368
     1369  idTest(h2);
    13581370
    13591371  h3 = kStd(h2,currQuotient,hom,w,NULL,syzcomp);
     1372
     1373#if MYTEST
     1374#ifdef RDEBUG
     1375  Print("Prepare::Output: ");
     1376  idPrint(h3);
     1377  for(j=0;j<IDELEMS(h2);j++) pTest(h3->m[j]);
     1378#endif
     1379#endif
     1380
     1381
    13601382  idDelete(&h2);
    13611383  return h3;
     
    13771399  int ii, idElemens_h1;
    13781400
     1401  assume(h1 != NULL);
     1402
    13791403  idElemens_h1=IDELEMS(h1);
    13801404#ifdef PDEBUG
     
    14121436  }
    14131437
    1414   ideal s_h3=idPrepare(s_h1,h,k,w);
     1438  idTest(s_h1);
     1439
     1440  ideal s_h3=idPrepare(s_h1,h,k,w); // main (syz) GB computation
    14151441
    14161442  if (s_h3==NULL)
     
    15891615#if MYTEST
    15901616#ifdef RDEBUG
    1591   Print("Input: ");
     1617  Print("idLiftStd Input: ");
    15921618  idPrint(s_h1);
    15931619#endif
     
    15991625#if MYTEST
    16001626#ifdef RDEBUG
    1601   Print("Prepare: ");
     1627  Print("idLiftStd Prepare: ");
    16021628  idPrint(s_h3);
    16031629#endif
     
    16081634#if MYTEST
    16091635#ifdef RDEBUG
    1610   Print("Temp: ");
     1636  Print("idLiftStd Temp: ");
    16111637  idPrint(s_h2);
    16121638#endif
     
    16461672#if MYTEST
    16471673#ifdef RDEBUG
    1648   Print("Input'': ");
     1674  Print("idLiftStd Input'': ");
    16491675  idPrint(s_h3);
    16501676#endif
     
    16561682#if MYTEST
    16571683#ifdef RDEBUG
    1658   Print("Temp Result: ");
     1684  Print("idLiftStd Temp Result: ");
    16591685  idPrint(s_h2);
    16601686#endif
     
    17011727#if MYTEST
    17021728#ifdef RDEBUG
    1703   Print("Output STD Ideal: ");
     1729  Print("idLiftStd Output STD Ideal: ");
    17041730  idPrint(s_h3);
    17051731
    1706   Print("Output Matrix: ");
     1732  Print("idLiftStd Output Matrix: ");
    17071733  iiWriteMatrix(*ma, "ma", 2, 4);
    17081734#endif
  • kernel/ideals.h

    r45c67dc r645a19  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: ideals.h,v 1.13 2009-02-12 16:19:23 motsak Exp $ */
     6/* $Id: ideals.h,v 1.14 2009-07-20 12:00:50 motsak Exp $ */
    77/*
    88* ABSTRACT - all basic methods to manipulate ideals
     
    2222void id_ShallowDelete (ideal* h, ring r);
    2323/* Shows an ideal -- mainly for debugging */
    24 void idShow(ideal id);
     24void idShow(const ideal id, const ring lmRing = currRing, const ring tailRing = currRing, const int debugPrint = 0);
    2525  /*- initialise an ideal -*/
    2626ideal idMaxIdeal (int deg);
  • kernel/kstd1.cc

    r45c67dc r645a19  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd1.cc,v 1.55 2009-07-17 11:31:10 Singular Exp $ */
     4/* $Id: kstd1.cc,v 1.56 2009-07-20 12:00:50 motsak Exp $ */
    55/*
    66* ABSTRACT:
    77*/
    88
     9// TODO: why the following is here instead of mod2.h???
     10
     11// define if tailrings should be used
     12#define HAVE_TAIL_RING
     13
    914// define if buckets should be used
    1015#define MORA_USE_BUCKETS
    1116
    12 // define if tailrings should be used
    13 #define HAVE_TAIL_RING
    14 
    1517#include "mod2.h"
     18
     19#ifndef NDEBUG
     20# define MYTEST 0
     21#else /* ifndef NDEBUG */
     22# define MYTEST 0
     23#endif /* ifndef NDEBUG */
     24
     25#if MYTEST
     26#ifdef HAVE_TAIL_RING
     27#undef HAVE_TAIL_RING
     28#endif /* ifdef HAVE_TAIL_RING */
     29#endif /* if MYTEST */
     30
    1631#include "structs.h"
    1732#include "omalloc.h"
     
    16831698          int newIdeal, intvec *vw)
    16841699{
     1700  if(idIs0(F))
     1701    return idInit(1,F->rank);
     1702
    16851703  ideal r;
    16861704  BOOLEAN b=pLexOrder,toReset=FALSE;
     
    17431761#ifdef KDEBUG
    17441762  idTest(F);
     1763  idTest(Q);
     1764
     1765#if MYTEST
     1766  PrintS("kSTD: currRing: "); rWrite(currRing);
     1767#endif
     1768
    17451769#endif
    17461770#ifdef HAVE_PLURAL
     
    18911915              int syzComp, int reduced)
    18921916{
     1917  if(idIs0(F))
     1918    return idInit(1,F->rank);
     1919
    18931920  ideal r=NULL;
    18941921  int Kstd1_OldDeg = Kstd1_deg,i;
     
    20172044  if (p==NULL)
    20182045     return NULL;
     2046
     2047  poly pp = p;
     2048
     2049#ifdef HAVE_PLURAL
     2050  if(rIsSCA(currRing))
     2051  {
     2052    const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     2053    const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     2054    pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing);
     2055
     2056    if(Q == currQuotient)
     2057      Q = SCAQuotient(currRing);
     2058  }
     2059#endif
     2060
    20192061  if ((idIs0(F))&&(Q==NULL))
     2062  {
     2063#ifdef HAVE_PLURAL
     2064    if(p != pp)
     2065      return pp;
     2066#endif
    20202067    return pCopy(p); /*F+Q=0*/
     2068  }
     2069
     2070
    20212071  kStrategy strat=new skStrategy;
    20222072  strat->syzComp = syzComp;
    20232073  strat->ak = si_max(idRankFreeModule(F),pMaxComp(p));
    20242074
    2025   poly pp = p;
    2026 
    2027 #ifdef HAVE_PLURAL
    2028   if(rIsSCA(currRing))
    2029   {
    2030     const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
    2031     const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
    2032     pp = p_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing);
    2033 
    2034     if(Q == currQuotient)
    2035       Q = SCAQuotient(currRing);
    2036   }
    2037 #endif
     2075
    20382076
    20392077  poly res;
     
    20622100  if (idIs0(p))
    20632101    return idInit(IDELEMS(p),si_max(p->rank,F->rank));
     2102
     2103  ideal pp = p;
     2104#ifdef HAVE_PLURAL
     2105  if(rIsSCA(currRing))
     2106  {
     2107    const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
     2108    const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
     2109    pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false);
     2110
     2111    if(Q == currQuotient)
     2112      Q = SCAQuotient(currRing);
     2113  }
     2114#endif
     2115
     2116
    20642117  if ((idIs0(F))&&(Q==NULL))
     2118  {
     2119#ifdef HAVE_PLURAL
     2120    if(p != pp)
     2121      return pp;
     2122#endif
     2123
    20652124    return idCopy(p); /*F+Q=0*/
     2125  }
    20662126
    20672127  kStrategy strat=new skStrategy;
     
    20692129  strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(p));
    20702130
    2071   ideal pp = p;
    2072 #ifdef HAVE_PLURAL
    2073   if(rIsSCA(currRing))
    2074   {
    2075     const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
    2076     const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
    2077     pp = id_KillSquares(pp, m_iFirstAltVar, m_iLastAltVar, currRing, false);
    2078 
    2079     if(Q == currQuotient)
    2080       Q = SCAQuotient(currRing);
    2081   }
    2082 #endif
    20832131
    20842132  if (pOrdSgn==-1)
  • kernel/kstd2.cc

    r45c67dc r645a19  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd2.cc,v 1.98 2009-07-17 09:51:42 Singular Exp $ */
     4/* $Id: kstd2.cc,v 1.99 2009-07-20 12:00:51 motsak Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: alg. of Buchberger
     
    88
    99// #define PDEBUG 2
     10
     11// TODO: why the following is here instead of mod2.h???
     12
    1013// define to enable tailRings
    1114#define HAVE_TAIL_RING
     15
     16#include "mod2.h"
     17
     18#ifndef NDEBUG
     19# define MYTEST 0
     20#else /* ifndef NDEBUG */
     21# define MYTEST 0
     22#endif /* ifndef NDEBUG */
     23
     24#if MYTEST
     25# ifdef HAVE_TAIL_RING
     26#  undef HAVE_TAIL_RING
     27# endif // ifdef HAVE_TAIL_RING
     28#endif
     29
    1230// define if no buckets should be used
    1331// #define NO_BUCKETS
    1432
    15 #include "mod2.h"
    1633#ifdef HAVE_PLURAL
    1734#define PLURAL_INTERNAL_DECLARATIONS 1
     
    946963#ifdef KDEBUG
    947964static int bba_count = 0;
    948 #endif
     965#endif /* KDEBUG */
    949966void kDebugPrint(kStrategy strat);
    950967
     
    954971  bba_count++;
    955972  int loop_count = 0;
    956 #endif
     973#endif /* KDEBUG */
    957974  om_Opts.MinTrack = 5;
    958975  int   srmax,lrmax, red_result = 1;
     
    9831000  kTest_TS(strat);
    9841001
     1002#ifdef KDEBUG
     1003#if MYTEST
     1004  PrintS("bba start GB: currRing: ");
     1005  rWrite(currRing);PrintLn(); rDebugPrint(currRing);
     1006  PrintLn();
     1007
     1008  if(strat->tailRing != NULL && strat->tailRing != currRing)
     1009  {
     1010    PrintS("bba start GB: tailRing: ");
     1011    rWrite(strat->tailRing);PrintLn(); rDebugPrint(strat->tailRing);
     1012  }
     1013#endif /* MYTEST */
     1014#endif /* KDEBUG */
     1015
    9851016#ifdef HAVE_TAIL_RING
    986   kStratInitChangeTailRing(strat);
     1017  if(!idIs0(F))
     1018    kStratInitChangeTailRing(strat);
    9871019#endif
    9881020  if (BVERBOSE(23))
     
    10931125      int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
    10941126
     1127#ifdef KDEBUG
     1128#if MYTEST
     1129      PrintS("New S: "); pDebugPrint(strat->P.p); PrintLn();
     1130#endif /* MYTEST */
     1131#endif /* KDEBUG */
     1132
    10951133      // reduce the tail and normalize poly
    10961134      // in the ring case we cannot expect LC(f) = 1,
     
    11141152#ifdef KDEBUG
    11151153      if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
    1116 #endif
     1154#if MYTEST
     1155      PrintS("New (reduced) S: "); pDebugPrint(strat->P.p); PrintLn();
     1156#endif /* MYTEST */
     1157#endif /* KDEBUG */
    11171158
    11181159      // min_std stuff
     
    11851226#ifdef KDEBUG
    11861227    memset(&(strat->P), 0, sizeof(strat->P));
    1187 #endif
     1228#endif /* KDEBUG */
    11881229    kTest_TS(strat);
    11891230  }
    11901231#ifdef KDEBUG
     1232#if MYTEST
     1233  PrintS("bba finish GB: currRing: "); rWrite(currRing);
     1234#endif /* MYTEST */
    11911235  if (TEST_OPT_DEBUG) messageSets(strat);
    1192 #endif
     1236#endif /* KDEBUG */
     1237
    11931238  if (TEST_OPT_SB_1)
    11941239  {
     
    12401285  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
    12411286  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     1287
     1288#ifdef KDEBUG
     1289#if MYTEST
     1290  PrintS("bba_end: currRing: "); rWrite(currRing);
     1291#endif /* MYTEST */
     1292#endif /* KDEBUG */
     1293  idTest(strat->Shdl);
     1294
    12421295  return (strat->Shdl);
    12431296}
     
    12461299{
    12471300  assume(q!=NULL);
    1248   assume(!(idIs0(F)&&(Q==NULL)));
     1301  assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring?
    12491302
    12501303// lazy_reduce flags: can be combined by |
  • kernel/kutil.cc

    r45c67dc r645a19  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.147 2009-07-10 15:13:56 Singular Exp $ */
     4/* $Id: kutil.cc,v 1.148 2009-07-20 12:00:51 motsak Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    1313#include <string.h>
    1414#include "mod2.h"
     15
     16#ifndef NDEBUG
     17# define MYTEST 0
     18#else /* ifndef NDEBUG */
     19# define MYTEST 0
     20#endif /* ifndef NDEBUG */
     21
     22
    1523#include <mylimits.h>
    1624#include "structs.h"
     
    13931401  pSetm(Lp.lcm);
    13941402
    1395 #define MYTEST 0
    13961403
    13971404  if (strat->sugarCrit && ALLOW_PROD_CRIT(strat))
     
    62396246BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject* T, unsigned long expbound)
    62406247{
     6248  assume(strat->tailRing == currRing);
     6249
    62416250  if (expbound == 0) expbound = strat->tailRing->bitmask << 1;
    62426251  if (expbound >= currRing->bitmask) return FALSE;
     
    62486257                                  (strat->homog && pFDeg == pDeg && !(rField_is_Ring(currRing))), // TODO Oliver
    62496258#else
    6250                                   (strat->homog && pFDeg == pDeg),
    6251 #endif
    6252                                   !strat->ak,
    6253                                   expbound);
     6259                                  (strat->homog && pFDeg == pDeg), // omit_degree
     6260#endif
     6261                                  (strat->ak==0), // omit_comp if the input is an ideal
     6262                                  expbound); // exp_limit
     6263
    62546264  if (new_tailRing == currRing) return TRUE;
    62556265
     
    63416351  int i;
    63426352  Exponent_t e;
    6343   ring new_tailRing;
     6353//  ring new_tailRing; // What for???
    63446354
    63456355  assume(strat->tailRing == currRing);
  • kernel/pInline2.h

    r45c67dc r645a19  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: pInline2.h,v 1.16 2009-05-29 13:57:35 motsak Exp $
     9 *  Version: $Id: pInline2.h,v 1.17 2009-07-20 12:00:51 motsak Exp $
    1010 *******************************************************************/
    1111#ifndef PINLINE2_H
     
    5050        return (((long)((p)->exp[r->pOrdIndex]))-POLY_NEGWEIGHT_OFFSET);
    5151      case ro_syzcomp:
    52       case ro_syz:
     52      case ro_syz: case ro_isTemp:  case ro_is:
    5353      case ro_cp:
    5454        i++;
     
    7575        return (p)->exp[r->pOrdIndex]=o+POLY_NEGWEIGHT_OFFSET;
    7676      case ro_syzcomp:
    77       case ro_syz:
     77      case ro_syz:  case ro_isTemp: case ro_is:
    7878      case ro_cp:
    7979        i++;
     
    197197  // 1, 2, 3 - anything like 00011..11
    198198  pAssume2((twobits >> 2) == 0);
    199   const unsigned long _bitmasks[4] = {-1, 0x7fff, 0x7f, 0x3};
    200   return bitmask & _bitmasks[twobits]; 
    201 }
    202 
    203 
    204 /// @Note: we may add some more info (6 ) into VarOffset and thus encode 
     199  static const unsigned long _bitmasks[4] = {-1, 0x7fff, 0x7f, 0x3};
     200  return bitmask & _bitmasks[twobits];
     201}
     202
     203
     204/// @Note: we may add some more info (6 ) into VarOffset and thus encode
    205205PINLINE2 int p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
    206206{
  • kernel/p_polys.cc

    r45c67dc r645a19  
    77 *  Author:  obachman (Olaf Bachmann)
    88 *  Created: 8/00
    9  *  Version: $Id: p_polys.cc,v 1.17 2009-06-10 15:34:50 Singular Exp $
     9 *  Version: $Id: p_polys.cc,v 1.18 2009-07-20 12:00:51 motsak Exp $
    1010 *******************************************************************/
    1111
     
    173173          break;
    174174        }
     175        // Prefix for Induced Schreyer ordering
     176        case ro_isTemp: // Do nothing?? (to be removed into suffix later on...?)
     177        {
     178          assume(p != NULL);
     179
     180#ifndef NDEBUG
     181#if MYTEST
     182          Print("isTemp ord in rSetm: pos: %d, p: ", pos);  p_DebugPrint(p, r, r, 0);
     183#endif
     184#endif
     185          int c = p_GetComp(p, r);
     186
     187          assume( c >= 0 );
     188          const int limit = o->data.is.limit;
     189
     190          assume( limit >= 0 );
     191
     192          // Let's simulate case ro_syz above....
     193          // Should accumulate (by Suffix) and be a level indicator
     194          const int* const pVarOffset = o->data.isTemp.pVarOffset;
     195
     196          assume( pVarOffset != NULL );
     197
     198          if( c > limit )
     199            p->exp[o->data.isTemp.start] = 1;
     200          else
     201          {
     202            p->exp[o->data.isTemp.start] = 0;
     203          }
     204
     205          // TODO: Can this be done in the suffix???
     206          for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
     207          {
     208            const int vo = pVarOffset[i];
     209            if( vo != -1) // TODO: optimize: can be done once!
     210            {
     211              p_SetExp(p, p_GetExp(p, i, r), r, vo); // copy put them verbatim
     212              assume( p_GetExp(p, r, vo) == p_GetExp(p, i, r) ); // copy put them verbatim
     213            }
     214          }
     215
     216       
     217
     218#ifndef NDEBUG
     219          for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
     220          {
     221            const int vo = pVarOffset[i];
     222            if( vo != -1) // TODO: optimize: can be done once!
     223            {
     224              assume( p_GetExp(p, r, vo) == p_GetExp(p, i, r) ); // copy put them verbatim
     225            }
     226          }
     227
     228#if MYTEST
     229//          if( p->exp[o->data.isTemp.start] > 0 )
     230//          {
     231//            PrintS("Initial Value: "); p_DebugPrint(p, r, r, 1);
     232//          }
     233#endif
     234#endif
     235
     236          break;
     237        }
     238
     239        // Suffix for Induced Schreyer ordering
     240        case ro_is:
     241        {
     242          assume(p != NULL);
     243
     244          int c = p_GetComp(p, r);
     245
     246          assume( c >= 0 );
     247          const ideal F = o->data.is.F;
     248          const int limit = o->data.is.limit;
     249
     250          if( F != NULL && c > limit )
     251          {
     252#ifndef NDEBUG
     253#if MYTEST
     254            Print("is ord in rSetm: pos: %d, c: %d, limit: %d\n", c, pos, limit); // p_DebugPrint(p, r, r, 1);
     255#endif
     256#endif
     257
     258            c -= limit;
     259            assume( c > 0 );
     260            c--;
     261
     262            assume( c < IDELEMS(F) ); // What about others???
     263
     264            const poly pp = F->m[c]; // get reference monomial!!!
     265
     266
     267#ifndef NDEBUG
     268#if MYTEST
     269            Print("Respective F[c - %d: %d] pp: ", limit, c);
     270            p_DebugPrint(pp, r, r, 1);
     271#endif
     272#endif
     273
     274
     275            if(pp == NULL) break;
     276
     277            const int start = o->data.is.start;
     278            const int end = o->data.is.end;
     279
     280            assume(start <= end);
     281            assume(pp != NULL);
     282
     283            for( int i = start; i <= end; i++) // v[0] may be here...
     284              p->exp[i] += pp->exp[i]; // !!!!!!!! ADD corresponding LT(F)
     285
     286#ifndef NDEBUG
     287            const int* const pVarOffset = o->data.is.pVarOffset;
     288
     289            assume( pVarOffset != NULL );
     290
     291            for( int i = 1; i <= r->N; i++ ) // No v[0] here!!!
     292            {
     293              const int vo = pVarOffset[i];
     294              if( vo != -1) // TODO: optimize: can be done once!
     295                assume( p_GetExp(p, r, vo) == (p_GetExp(p, i, r) + p_GetExp(pp, r, vo)) );
     296            }
     297            // TODO: how to check this for computed values???
     298#endif
     299#ifndef NDEBUG
     300#if MYTEST
     301            PrintS("IS::Suffix::Result: "); // p_Write(p, r, r);
     302            p_DebugPrint(p, r, r, 1);
     303#endif
     304#endif
     305
     306          } else
     307          {
     308            const int* const pVarOffset = o->data.is.pVarOffset;
     309
     310            // What about v[0] - component: it will be added later by
     311            // suffix!!!
     312            // TODO: Test it!
     313            const int vo = pVarOffset[0];
     314            if( vo != -1 )
     315              p->exp[vo] = c; // initial component v[0]!
     316          }
     317
     318          break;
     319        }
    175320        default:
    176321          dReportError("wrong ord in rSetm:%d\n",o->ord_typ);
     
    337482      case ringorder_S:
    338483      case ringorder_s:
     484      case ringorder_IS:
    339485      case ringorder_aa:
    340486        break;
  • kernel/ring.cc

    r45c67dc r645a19  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ring.cc,v 1.122 2009-07-10 15:13:57 Singular Exp $ */
     4/* $Id: ring.cc,v 1.123 2009-07-20 12:00:51 motsak Exp $ */
    55
    66/*
     
    1111#include <math.h>
    1212#include "mod2.h"
     13
     14#ifndef NDEBUG
     15# define MYTEST 0
     16#else /* ifndef NDEBUG */
     17# define MYTEST 0
     18#endif /* ifndef NDEBUG */
     19
    1320#include "structs.h"
    1421#include "omalloc.h"
     
    3845static const char * const ringorder_name[] =
    3946{
    40   " ?", //ringorder_no = 0,
    41   "a", //ringorder_a,
    42   "A", //ringorder_a64,
    43   "c", //ringorder_c,
    44   "C", //ringorder_C,
    45   "M", //ringorder_M,
    46   "S", //ringorder_S,
    47   "s", //ringorder_s,
    48   "lp", //ringorder_lp,
    49   "dp", //ringorder_dp,
    50   "rp", //ringorder_rp,
    51   "Dp", //ringorder_Dp,
    52   "wp", //ringorder_wp,
    53   "Wp", //ringorder_Wp,
    54   "ls", //ringorder_ls,
    55   "ds", //ringorder_ds,
    56   "Ds", //ringorder_Ds,
    57   "ws", //ringorder_ws,
    58   "Ws", //ringorder_Ws,
    59   "L", //ringorder_L,
    60   "aa", //ringorder_aa
    61   "rs", //ringorder_rs,
    62   " _" //ringorder_unspec
     47  " ?", ///< ringorder_no = 0,
     48  "a", ///< ringorder_a,
     49  "A", ///< ringorder_a64,
     50  "c", ///< ringorder_c,
     51  "C", ///< ringorder_C,
     52  "M", ///< ringorder_M,
     53  "S", ///< ringorder_S,
     54  "s", ///< ringorder_s,
     55  "lp", ///< ringorder_lp,
     56  "dp", ///< ringorder_dp,
     57  "rp", ///< ringorder_rp,
     58  "Dp", ///< ringorder_Dp,
     59  "wp", ///< ringorder_wp,
     60  "Wp", ///< ringorder_Wp,
     61  "ls", ///< ringorder_ls,
     62  "ds", ///< ringorder_ds,
     63  "Ds", ///< ringorder_Ds,
     64  "ws", ///< ringorder_ws,
     65  "Ws", ///< ringorder_Ws,
     66  "L", ///< ringorder_L,
     67  "aa", ///< ringorder_aa
     68  "rs", ///< ringorder_rs,
     69  "IS", ///<  ringorder_IS
     70  " _" ///< ringorder_unspec
    6371};
    6472
     
    6876}
    6977
    70 // unconditionally deletes fields in r
     78/// unconditionally deletes fields in r
    7179void rDelete(ring r);
    72 // set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex
     80/// set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex
    7381static void rSetVarL(ring r);
    74 // get r->divmask depending on bits per exponent
     82/// get r->divmask depending on bits per exponent
    7583static unsigned long rGetDivMask(int bits);
    76 // right-adjust r->VarOffset
     84/// right-adjust r->VarOffset
    7785static void rRightAdjustVarOffset(ring r);
    7886static void rOptimizeLDeg(ring r);
     
    8896//}
    8997
    90 // internally changes the gloabl ring and resets the relevant
    91 // global variables:
     98/// internally changes the gloabl ring and resets the relevant
     99/// global variables:
    92100void rChangeCurrRing(ring r)
    93101{
     
    358366    Print("ordering %s", rSimpleOrdStr(r->order[l]));
    359367
    360     if ((r->order[l] >= ringorder_lp)
     368
     369    if (r->order[l] == ringorder_s)
     370    {
     371      assume( l == 0 );
     372#ifndef NDEBUG
     373      Print("  syzcomp at %d",r->typ[l].data.syz.limit);
     374#endif
     375      continue;
     376    }
     377    else if (r->order[l] == ringorder_IS)
     378    {
     379#ifndef NDEBUG
     380      if(r->block0[l] == 0 )
     381        Print("::prefix");
     382      else
     383        Print("::suffix (sign: %d)", r->block0[l]);
     384#endif
     385      continue;
     386    } else
     387    if (
     388    (  (r->order[l] >= ringorder_lp)
    361389    ||(r->order[l] == ringorder_M)
    362390    ||(r->order[l] == ringorder_a)
    363391    ||(r->order[l] == ringorder_a64)
    364     ||(r->order[l] == ringorder_aa))
     392    ||(r->order[l] == ringorder_aa) ) && (r->order[l] < ringorder_IS) )
    365393    {
    366394      PrintS("\n//                  : names   ");
     
    371399      }
    372400    }
    373 #ifndef NDEBUG
    374     else if (r->order[l] == ringorder_s)
    375     {
    376       Print("  syzcomp at %d",r->typ[l].data.syz.limit);
    377     }
    378 #endif
    379401
    380402    if (r->wvhdl[l]!=NULL)
     
    391413            int64 *w=(int64 *)r->wvhdl[l];
    392414            #if SIZEOF_LONG == 4
    393             Print(" %*lld" ,nlen,w[i+j],i+j);
     415                  Print("%*lld " ,nlen,w[i+j],i+j);
    394416            #else
    395417            Print(" %*ld"  ,nlen,w[i+j],i+j);
     
    14831505 * DOES NOT CALL rComplete
    14841506 */
    1485 ring rCopy0(ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
     1507ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
    14861508{
    14871509  if (r == NULL) return NULL;
     
    16231645  if (r->qideal!=NULL)
    16241646  {
    1625     if (copy_qideal) res->qideal= idrCopyR_NoSort(r->qideal, r);
     1647    if (copy_qideal) res->qideal= idrCopyR_NoSort(r->qideal, r, res);
    16261648    //memset: else res->qideal = NULL;
    16271649  }
     
    19281950    {
    19291951      sro_ord* o=&(r->typ[pos]);
    1930       if ((o->ord_typ == ro_syzcomp) || (o->ord_typ == ro_syz)) return TRUE;
     1952      if ((o->ord_typ == ro_syzcomp) || (o->ord_typ == ro_syz) || (o->ord_typ == ro_is) || (o->ord_typ == ro_isTemp)) return TRUE;
    19311953    }
    19321954  }
     
    20372059  omCheckAddrSize(r->VarOffset,(r->N+1)*sizeof(*(r->VarOffset)));
    20382060  // test assumptions:
    2039   for(i=0;i<=r->N;i++)
     2061  for(i=0;i<=r->N;i++) // for all variables (i = 0..N)
    20402062  {
    20412063    if(r->typ!=NULL)
    20422064    {
    2043       for(j=0;j<r->OrdSize;j++)
    2044       {
    2045         if (r->typ[j].ord_typ==ro_cp)
    2046         {
    2047           if(((short)r->VarOffset[i]) == r->typ[j].data.cp.place)
    2048             dReportError("ordrec %d conflicts with var %d",j,i);
    2049         }
    2050         else
    2051           if ((r->typ[j].ord_typ!=ro_syzcomp)
    2052           && (r->VarOffset[i] == r->typ[j].data.dp.place))
    2053             dReportError("ordrec %d conflicts with var %d",j,i);
     2065      for(j=0;j<r->OrdSize;j++) // for all ordering blocks (j =0..OrdSize-1)
     2066      {
     2067        if(r->typ[j].ord_typ == ro_isTemp)
     2068        {
     2069          const int p = r->typ[j].data.isTemp.suffixpos;
     2070
     2071          if(p <= j)
     2072            dReportError("ordrec prefix %d is unmatched",j);
     2073
     2074          assume( p < r->OrdSize );
     2075
     2076          if(r->typ[p].ord_typ != ro_is)
     2077            dReportError("ordrec prefix %d is unmatched (suffix: %d is wrong!!!)",j, p);
     2078
     2079          // Skip all intermediate blocks for undone variables:
     2080          if(r->typ[j].data.isTemp.pVarOffset[i] != -1) // Check i^th variable
     2081          {
     2082            j = p - 1; // SKIP ALL INTERNAL BLOCKS...???
     2083            continue; // To make for check OrdSize bound...
     2084          }
     2085        } else
     2086        if (r->typ[j].ord_typ == ro_is)
     2087        {
     2088          // Skip all intermediate blocks for undone variables:
     2089          if(r->typ[j].data.is.pVarOffset[i] != -1)
     2090          {
     2091            // ???
     2092          }
     2093
     2094        } else
     2095        {
     2096          if (r->typ[j].ord_typ==ro_cp)
     2097          {
     2098            if(((short)r->VarOffset[i]) == r->typ[j].data.cp.place)
     2099              dReportError("ordrec %d conflicts with var %d",j,i);
     2100          }
     2101          else
     2102            if ((r->typ[j].ord_typ!=ro_syzcomp)
     2103            && (r->VarOffset[i] == r->typ[j].data.dp.place))
     2104              dReportError("ordrec %d conflicts with var %d",j,i);
     2105        }
    20542106      }
    20552107    }
     
    23272379}
    23282380
     2381
     2382static void rO_ISPrefix(int &place, int &bitplace, int &prev_ord,
     2383    long *o, int N, int *v, sro_ord &ord_struct)
     2384{
     2385  if ((prev_ord== 1) || (bitplace!=BITS_PER_LONG))
     2386    rO_Align(place,bitplace);
     2387  // since we add something afterwards - it's better to start with anew!?
     2388
     2389  ord_struct.ord_typ = ro_isTemp;
     2390  ord_struct.data.isTemp.start = place;
     2391  ord_struct.data.isTemp.pVarOffset = (int *)omMemDup(v);
     2392  ord_struct.data.isTemp.suffixpos = -1;
     2393
     2394  // We will act as rO_Syz on our own!!!
     2395  // Here we allocate an exponent as a level placeholder
     2396  o[place]= -1;
     2397  prev_ord=-1;
     2398  place++;
     2399
     2400#if MYTEST
     2401  Print("rO_ISPrefix: place = %d, v: {", ord_struct.data.isTemp.start);
     2402
     2403  for( int i = 0; i <= N; i++ )
     2404    Print("v[%d]: %09x", i, ord_struct.data.isTemp.pVarOffset[i]);
     2405
     2406  PrintS("}!\n");
     2407#endif
     2408}
     2409static void rO_ISSuffix(int &place, int &bitplace, int &prev_ord, long *o,
     2410  int N, int *v, sro_ord *tmp_typ, int &typ_i, int sgn)
     2411{
     2412#if MYTEST
     2413  Print("rO_ISSuffix: place = %d\n", place);
     2414#endif
     2415
     2416  // Let's find previous prefix:
     2417  int typ_j = typ_i - 1;
     2418  while(typ_j >= 0)
     2419  {
     2420    if( tmp_typ[typ_j].ord_typ == ro_isTemp)
     2421      break;
     2422    typ_j --;
     2423  }
     2424
     2425  assume( typ_j >= 0 );
     2426
     2427  if( typ_j < 0 ) // Found NO prefix!!! :(
     2428    return;
     2429
     2430  assume( tmp_typ[typ_j].ord_typ == ro_isTemp );
     2431
     2432  // Get saved state:
     2433  const int start = tmp_typ[typ_j].data.isTemp.start;
     2434  int *pVarOffset = tmp_typ[typ_j].data.isTemp.pVarOffset;
     2435
     2436/*
     2437  // shift up all blocks
     2438  while(typ_j < (typ_i-1))
     2439  {
     2440    tmp_typ[typ_j] = tmp_typ[typ_j+1];
     2441    typ_j++;
     2442  }
     2443  typ_j = typ_i - 1; // No increment for typ_i
     2444*/
     2445  tmp_typ[typ_j].data.isTemp.suffixpos = typ_i;
     2446
     2447  // Let's keep that dummy for now...
     2448  typ_j = typ_i; // the typ to change!
     2449  typ_i++; // Just for now...
     2450
     2451
     2452#if MYTEST
     2453  PrintS("Changes in v: {");
     2454#endif
     2455
     2456  for( int i = 0; i <= N; i++ ) // Note [0] == component !!! No Skip?
     2457  {
     2458    // Was i-th variable allocated inbetween?
     2459    if( v[i] != pVarOffset[i] )
     2460    {
     2461      pVarOffset[i] = v[i]; // Save for later...
     2462      v[i] = -1; // Undo!
     2463      assume( pVarOffset[i] != -1 );
     2464#if MYTEST
     2465      Print("v[%d]: %010x", i, pVarOffset[i]);
     2466#endif
     2467    } else
     2468      pVarOffset[i] = -1; // No change here...
     2469  }
     2470
     2471  if( pVarOffset[0] != -1 )
     2472    pVarOffset[0] &= 0x0fff;
     2473
     2474#if MYTEST
     2475  PrintS("}!\n");
     2476#endif
     2477  sro_ord &ord_struct = tmp_typ[typ_j];
     2478
     2479
     2480  ord_struct.ord_typ = ro_is;
     2481  ord_struct.data.is.start = start;
     2482  ord_struct.data.is.end   = place;
     2483  ord_struct.data.is.pVarOffset = pVarOffset;
     2484
     2485
     2486  // What about component???
     2487//   if( v[0] != -1 ) // There is a component already...???
     2488//     if( o[ v[0] & 0x0fff ] == sgn )
     2489//     {
     2490//       pVarOffset[0] = -1; // NEVER USED Afterwards...
     2491//       return;
     2492//     }
     2493
     2494 
     2495  // Moreover: we need to allocate the module component (v[0]) here!
     2496  if( v[0] == -1) // It's possible that there was module component v0 at the begining (before prefix)!
     2497  {
     2498    // Start with a whole long exponent
     2499    if( bitplace != BITS_PER_LONG )
     2500      rO_Align(place, bitplace);
     2501
     2502    assume( bitplace == BITS_PER_LONG );
     2503    bitplace -= BITS_PER_LONG;
     2504    assume(bitplace == 0);
     2505    v[0] = place | (bitplace << 24); // Never mind whether pVarOffset[0] > 0!!!
     2506    o[place] = sgn; // Singnum for component ordering
     2507    prev_ord = sgn;
     2508  }
     2509}
     2510
     2511
    23292512static unsigned long rGetExpSize(unsigned long bitmask, int & bits)
    23302513{
     
    24472630  }
    24482631}
     2632
     2633
     2634bool rSetISReference(const ideal F, const int i, const int p, const intvec * componentWeights, const ring r);
     2635
    24492636
    24502637/*2
     
    24622649  BOOLEAN need_other_ring;
    24632650  BOOLEAN omitted_degree = FALSE;
     2651
     2652  int iNeedInducedOrderingSetup = 0; ///< How many induced ordering block do we have?
    24642653  int bits;
    24652654
     
    24752664  int i=0;
    24762665  int j=0; /*  i index in r, j index in res */
    2477   loop
     2666
     2667  for( int r_ord=r->order[i]; (r_ord != 0) && (i < nblocks); j++, r_ord=r->order[++i])
    24782668  {
    24792669    BOOLEAN copy_block_index=TRUE;
    2480     int r_ord=r->order[i];
     2670
    24812671    if (r->block0[i]==r->block1[i])
    24822672    {
     
    25012691    switch(r_ord)
    25022692    {
     2693      case ringorder_S:
     2694      {
     2695        dReportError("Error: unhandled ordering in rModifyRing: ringorder_S = [%d]", r_ord);
     2696        order[j]=r_ord; /*r->order[i];*/
     2697        break;
     2698      }
    25032699      case ringorder_C:
    25042700      case ringorder_c:
     
    25472743        }
    25482744        break;
     2745      case ringorder_IS:
     2746      {
     2747        if (omit_comp)
     2748        {
     2749          dReportError("Error: WRONG USAGE of rModifyRing: cannot omit component due to the ordering block [%d]: %d", i, r_ord);
     2750          omit_comp = FALSE;
     2751        }
     2752        order[j]=r_ord; /*r->order[i];*/
     2753        iNeedInducedOrderingSetup++;
     2754        break;
     2755      }
     2756      case ringorder_s:
     2757      {
     2758        assume((i == 0) && (j == 0));
     2759        if (omit_comp)
     2760        {
     2761          dReportError("Error: WRONG USAGE of rModifyRing: cannot omit component due to the ordering block [%d]: %d", i, r_ord);
     2762          omit_comp = FALSE;
     2763        }
     2764        order[j]=r_ord; /*r->order[i];*/
     2765        break;
     2766      }
    25492767      default:
    25502768        order[j]=r_ord; /*r->order[i];*/
     
    25572775      wvhdl[j]=r->wvhdl[i];
    25582776    }
    2559     i++;j++;
     2777
    25602778    // order[j]=ringorder_no; //  done by omAlloc0
    2561     if (i==nblocks) break;
    25622779  }
    25632780  if(!need_other_ring)
     
    26032820
    26042821  // set syzcomp
    2605   if (res->typ != NULL && res->typ[0].ord_typ == ro_syz)
    2606   {
    2607     res->typ[0] = r->typ[0];
    2608     if (r->typ[0].data.syz.limit > 0)
    2609     {
    2610       res->typ[0].data.syz.syz_index
    2611         = (int*) omAlloc((r->typ[0].data.syz.limit +1)*sizeof(int));
    2612       memcpy(res->typ[0].data.syz.syz_index, r->typ[0].data.syz.syz_index,
    2613              (r->typ[0].data.syz.limit +1)*sizeof(int));
    2614     }
     2822  if (res->typ != NULL)
     2823  {
     2824    if( res->typ[0].ord_typ == ro_syz) // "s" Always on [0] place!
     2825    {
     2826      res->typ[0] = r->typ[0]; // Copy struct!? + setup the same limit!
     2827
     2828      if (r->typ[0].data.syz.limit > 0)
     2829      {
     2830        res->typ[0].data.syz.syz_index
     2831          = (int*) omAlloc((r->typ[0].data.syz.limit +1)*sizeof(int));
     2832        memcpy(res->typ[0].data.syz.syz_index, r->typ[0].data.syz.syz_index,
     2833              (r->typ[0].data.syz.limit +1)*sizeof(int));
     2834      }
     2835    }
     2836
     2837    if( iNeedInducedOrderingSetup > 0 )
     2838    {
     2839      for(j = 0, i = 0; (i < nblocks) && (iNeedInducedOrderingSetup > 0); i++)
     2840        if( res->typ[i].ord_typ == ro_is ) // Search for suffixes!
     2841        {
     2842          ideal F = idrHeadR(r->typ[i].data.is.F, r, res); // Copy F from r into res!
     2843          assume(
     2844            rSetISReference(
     2845              F,  // WILL BE COPIED!
     2846              r->typ[i].data.is.limit,
     2847              j++,
     2848              r->typ[i].data.is.componentWeights, // WILL BE COPIED
     2849              res)
     2850            );
     2851          id_Delete(&F, res);
     2852          iNeedInducedOrderingSetup--;
     2853        }
     2854    } // Process all induced Ordering blocks! ...
    26152855  }
    26162856  // the special case: homog (omit_degree) and 1 block rs: that is global:
     
    26312871
    26322872      // just go on..
     2873    }
     2874
     2875    if( rIsSCA(r) )
     2876    {
     2877      if( !sca_Force(res, scaFirstAltVar(r), scaLastAltVar(r)) )
     2878      WarnS("error in sca_Force!");
    26332879    }
    26342880  }
     
    26862932}
    26872933
    2688 // construct lp ring with r->N variables, r->names vars....
     2934// construct lp, C ring with r->N variables, r->names vars....
    26892935ring rModifyRing_Simple(ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, unsigned long exp_limit, BOOLEAN &simple)
    26902936{
     
    28683114      r->MixedOrder=TRUE;
    28693115      break;
     3116    case ringorder_IS:
     3117    { // TODO: What is r->ComponentOrder???
     3118      r->MixedOrder=TRUE;
     3119/*
     3120      if( r->block0[o] != 0 ) // Suffix has the comonent
     3121        r->ComponentOrder = r->block0[o];
     3122      else // Prefix has level...
     3123        r->ComponentOrder=-1;
     3124*/
     3125      break;
     3126    }
     3127
    28703128    default:
    28713129      dReportError("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__);
     
    29393197  int** wvhdl = r->wvhdl;
    29403198
    2941   if (order[0]==ringorder_S ||order[0]==ringorder_s)
     3199  if (order[0]==ringorder_S ||order[0]==ringorder_s || order[0]==ringorder_IS)
    29423200  {
    29433201    order++;
     
    29563214      ||(
    29573215    ((order[1]==ringorder_c)||(order[1]==ringorder_C)
    2958      ||(order[1]==ringorder_S)
     3216     ||(order[1]==ringorder_S) ||(order[1]==ringorder_IS)
    29593217     ||(order[1]==ringorder_s))
    29603218    && (order[0]!=ringorder_M)
     
    29633221  {
    29643222    if ((order[0]!=ringorder_unspec)
    2965     && ((order[1]==ringorder_C)||(order[1]==ringorder_S)||
     3223    && ((order[1]==ringorder_C)||(order[1]==ringorder_S)||(order[1]==ringorder_IS)||
    29663224        (order[1]==ringorder_s)))
    29673225      r->ComponentOrder=-1;
     
    29883246  else if (((order[0]==ringorder_c)
    29893247            ||(order[0]==ringorder_C)
    2990             ||(order[0]==ringorder_S)
     3248            ||(order[0]==ringorder_S) ||(order[0]==ringorder_IS)
    29913249            ||(order[0]==ringorder_s))
    29923250  && (order[1]!=ringorder_M)
    29933251  &&  (order[2]==0))
    29943252  {
    2995     if ((order[0]==ringorder_C)||(order[0]==ringorder_S)||
     3253    if ((order[0]==ringorder_C)||(order[0]==ringorder_S)|| (order[0]==ringorder_IS) ||
    29963254        order[0]==ringorder_s)
    29973255      r->ComponentOrder=-1;
     
    30173275  else
    30183276  {
    3019     if ((r->VectorOut)||(order[0]==ringorder_C)||(order[0]==ringorder_S)||(order[0]==ringorder_s))
     3277    if ((r->VectorOut)||(order[0]==ringorder_C)||(order[0]==ringorder_S)||(order[0]==ringorder_s) ||(order[0]==ringorder_IS))
    30203278    {
    30213279      rSetFirstWv(r, 1, order, block1, wvhdl);
     
    30363294    if ((order[0]!=ringorder_c)
    30373295        && (order[0]!=ringorder_C)
    3038         && (order[0]!=ringorder_S)
     3296        && (order[0]!=ringorder_S) && (order[0]!=ringorder_IS)
    30393297        && (order[0]!=ringorder_s))
    30403298    {
     
    31413399  int j=0;
    31423400  int j_bits=BITS_PER_LONG;
    3143   BOOLEAN need_to_add_comp=FALSE;
     3401
     3402  BOOLEAN need_to_add_comp=FALSE; // Only for ringorder_s and ringorder_S!
     3403
    31443404  for(i=0;i<n;i++)
    31453405  {
     
    33413601
    33423602      case ringorder_S:
     3603        assume(typ_i == 0 && j == 0);
    33433604        rO_Syzcomp(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
    33443605        need_to_add_comp=TRUE;
     
    33473608
    33483609      case ringorder_s:
    3349         rO_Syz(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
     3610        assume(typ_i == 0 && j == 0);
     3611        rO_Syz(j, j_bits, prev_ordsgn, tmp_ordsgn, tmp_typ[typ_i]);
    33503612        need_to_add_comp=TRUE;
    33513613        typ_i++;
    33523614        break;
    33533615
     3616      case ringorder_IS:
     3617      {
     3618        const int s = r->block0[i];
     3619        assume( s >= -1 && s <= 1);
     3620
     3621        assume( r->block0[i] == r->block1[i] );
     3622
     3623        if(s == 0) // Prefix IS
     3624          rO_ISPrefix(j, j_bits, prev_ordsgn, tmp_ordsgn, r->N, v, tmp_typ[typ_i++]); // What about prev_ordsgn?
     3625        else // s = +1 or -1 // Note: typ_i might be incrimented here inside!
     3626        {
     3627          rO_ISSuffix(j, j_bits, prev_ordsgn, tmp_ordsgn, r->N, v, tmp_typ, typ_i, s); // Suffix.
     3628          need_to_add_comp=FALSE;
     3629        }
     3630
     3631        break;
     3632      }
    33543633      case ringorder_unspec:
    33553634      case ringorder_no:
     
    34413720  i=0; // position
    34423721  j=0; // index in r->typ
    3443   if (i==r->pCompIndex) i++;
     3722  if (i==r->pCompIndex) i++; // IS???
    34443723  while ((j < r->OrdSize)
    34453724         && ((r->typ[j].ord_typ==ro_syzcomp) ||
    3446              (r->typ[j].ord_typ==ro_syz) ||
     3725             (r->typ[j].ord_typ==ro_syz) || (r->typ[j].ord_typ==ro_isTemp) || (r->typ[j].ord_typ==ro_is) ||
    34473726             (r->order[r->typ[j].order_index] == ringorder_aa)))
    34483727  {
    34493728    i++; j++;
    34503729  }
     3730  // No use of j anymore!!!????
     3731
    34513732  if (i==r->pCompIndex) i++;
    3452   r->pOrdIndex=i;
     3733  r->pOrdIndex=i; // How came it is "i" here???!!!! exp[r->pOrdIndex] is order of a poly... This may be wrong!!! IS
    34533734
    34543735  // ----------------------------
     
    34833764  if (r->VarOffset != NULL)
    34843765  {
     3766    if (r->OrdSize!=0 && r->typ != NULL)
     3767    {
     3768      for(int i = 0; i < r->OrdSize; i++)
     3769        if( r->typ[i].ord_typ == ro_is) // Search for suffixes! (prefix have the same VarOffset)
     3770        {
     3771          id_Delete(&r->typ[i].data.is.F, r);
     3772          r->typ[i].data.is.F = NULL; // ?
     3773
     3774          if( r->typ[i].data.is.componentWeights != NULL )
     3775          {
     3776            delete r->typ[i].data.is.componentWeights;
     3777            r->typ[i].data.is.componentWeights = NULL; // ?
     3778          }
     3779         
     3780
     3781          if( r->typ[i].data.is.pVarOffset != NULL )
     3782          {
     3783            omFreeSize((ADDRESS)r->typ[i].data.is.pVarOffset, (r->N +1)*sizeof(int));
     3784            r->typ[i].data.is.pVarOffset = NULL; // ?
     3785          }
     3786        }
     3787        else if (r->typ[i].ord_typ == ro_syz)
     3788        {
     3789          if(r->typ[i].data.syz.limit > 0)
     3790            omFreeSize(r->typ[i].data.syz.syz_index, ((r->typ[i].data.syz.limit) +1)*sizeof(int));
     3791          r->typ[i].data.syz.syz_index = NULL;
     3792        } else if (r->typ[i].ord_typ == ro_syzcomp)
     3793        {
     3794          Warn( "rUnComplete : ord_typ == ro_syzcomp was unhandled!!! Possibly memory leak!!!"  );
     3795        }
     3796
     3797      omFreeSize((ADDRESS)r->typ,r->OrdSize*sizeof(sro_ord)); r->typ = NULL;
     3798    }
     3799
     3800    if (r->order != NULL)
     3801    {
     3802      // delete r->order!!!???
     3803    }
     3804
    34853805    if (r->PolyBin != NULL)
    34863806      omUnGetSpecBin(&(r->PolyBin));
    34873807
    34883808    omFreeSize((ADDRESS)r->VarOffset, (r->N +1)*sizeof(int));
    3489     if (r->order != NULL)
    3490     {
    3491       if (r->order[0] == ringorder_s && r->typ[0].data.syz.limit > 0)
    3492       {
    3493         omFreeSize(r->typ[0].data.syz.syz_index,
    3494              (r->typ[0].data.syz.limit +1)*sizeof(int));
    3495       }
    3496     }
    3497     if (r->OrdSize!=0 && r->typ != NULL)
    3498     {
    3499       omFreeSize((ADDRESS)r->typ,r->OrdSize*sizeof(sro_ord));
    3500     }
     3809   
    35013810    if (r->ordsgn != NULL && r->CmpL_Size != 0)
    35023811      omFreeSize((ADDRESS)r->ordsgn,r->ExpL_Size*sizeof(long));
     
    36183927  // corresponds to ro_typ from ring.h:
    36193928  const char *TYP[]={"ro_dp","ro_wp","ro_wp64","ro_wp_neg","ro_cp",
    3620                      "ro_syzcomp", "ro_syz", "ro_none"};
     3929                     "ro_syzcomp", "ro_syz", "ro_isTemp", "ro_is", "ro_none"};
    36213930  int i,j;
    36223931
     
    36403949  for(j=0;j<r->OrdSize;j++)
    36413950  {
    3642     Print("  typ %s",TYP[r->typ[j].ord_typ]);
    3643     Print("  place %d",r->typ[j].data.dp.place);
    3644     if (r->typ[j].ord_typ!=ro_syzcomp)
    3645     {
    3646       Print("  start %d",r->typ[j].data.dp.start);
    3647       Print("  end %d",r->typ[j].data.dp.end);
    3648       if ((r->typ[j].ord_typ==ro_wp)
    3649       || (r->typ[j].ord_typ==ro_wp_neg))
    3650       {
    3651         PrintS(" w:");
    3652         int l;
    3653         for(l=r->typ[j].data.wp.start;l<=r->typ[j].data.wp.end;l++)
    3654           Print(" %d",r->typ[j].data.wp.weights[l-r->typ[j].data.wp.start]);
    3655       }
    3656       else if (r->typ[j].ord_typ==ro_wp64)
    3657       {
    3658         PrintS(" w64:");
    3659         int l;
    3660         for(l=r->typ[j].data.wp64.start;l<=r->typ[j].data.wp64.end;l++)
    3661           Print(" %ld",(long)(((int64*)r->typ[j].data.wp64.weights64)+l-r->typ[j].data.wp64.start));
    3662       }
     3951    Print("  typ %s", TYP[r->typ[j].ord_typ]);
     3952
     3953    if (r->typ[j].ord_typ==ro_isTemp)
     3954    {
     3955      Print("  start (level) %d, suffixpos: %d, VO: ",r->typ[j].data.isTemp.start, r->typ[j].data.isTemp.suffixpos);
     3956
     3957#if MYTEST     
     3958      for( int k = 0; k <= r->N; k++)
     3959        if (r->typ[j].data.isTemp.pVarOffset[k] != -1)
     3960          Print("[%2d]: %09x; ", k, r->typ[j].data.isTemp.pVarOffset[k]);
     3961#endif
     3962    }
     3963    else
     3964    if (r->typ[j].ord_typ==ro_is)
     3965    {
     3966      Print("  start %d, end: %d: ",r->typ[j].data.is.start, r->typ[j].data.is.end);
     3967
     3968//      for( int k = 0; k <= r->N; k++) if (r->typ[j].data.is.pVarOffset[k] != -1) Print("[%2d]: %04x; ", k, r->typ[j].data.is.pVarOffset[k]);
     3969
     3970      Print("  limit %d\n  F: ",r->typ[j].data.is.limit); idShow(r->typ[j].data.is.F, r, r, 1);
     3971
     3972      PrintS("weights: ");
     3973     
     3974      if( r->typ[j].data.is.componentWeights == NULL )
     3975        PrintS("NULL == [0,...0]\n");
     3976      else
     3977      {
     3978        (r->typ[j].data.is.componentWeights)->show(); PrintLn();
     3979      }
     3980     
     3981    } else
     3982    {
     3983      Print("  place %d",r->typ[j].data.dp.place);
     3984
     3985      if (r->typ[j].ord_typ!=ro_syzcomp  && r->typ[j].ord_typ!=ro_syz)
     3986      {
     3987        Print("  start %d",r->typ[j].data.dp.start);
     3988        Print("  end %d",r->typ[j].data.dp.end);
     3989        if ((r->typ[j].ord_typ==ro_wp)
     3990        || (r->typ[j].ord_typ==ro_wp_neg))
     3991        {
     3992          PrintS(" w:");
     3993          for(int l=r->typ[j].data.wp.start;l<=r->typ[j].data.wp.end;l++)
     3994            Print(" %d",r->typ[j].data.wp.weights[l-r->typ[j].data.wp.start]);
     3995        }
     3996        else if (r->typ[j].ord_typ==ro_wp64)
     3997        {
     3998          PrintS(" w64:");
     3999          int l;
     4000          for(l=r->typ[j].data.wp64.start;l<=r->typ[j].data.wp64.end;l++)
     4001            Print(" %ld",(long)(((int64*)r->typ[j].data.wp64.weights64)+l-r->typ[j].data.wp64.start));
     4002          }
     4003        }
    36634004    }
    36644005    PrintLn();
     
    37394080#endif // RDEBUG
    37404081
     4082/// debug-print monomial poly/vector p, assuming that it lives in the ring R
     4083inline void m_DebugPrint(const poly p, const ring R)
     4084{
     4085  Print("\nexp[0..%d]\n", R->ExpL_Size - 1);
     4086  for(int i = 0; i < R->ExpL_Size; i++)
     4087    Print("%09lx ", p->exp[i]);
     4088  PrintLn();
     4089  Print("v0:%9ld ", p_GetComp(p, R));
     4090  for(int i = 1; i <= R->N; i++) Print(" v%d:%5d",i, p_GetExp(p, i, R));
     4091  PrintLn();
     4092}
     4093
     4094
     4095/// debug-print at most nTerms (2 by default) terms from poly/vector p,
     4096/// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
     4097void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms)
     4098{
     4099  assume( nTerms >= 0 );
     4100  if( p != NULL )
     4101  {
     4102    assume( p != NULL );
     4103   
     4104    p_Write(p, lmRing, tailRing);
     4105
     4106    if( (p != NULL) && (nTerms > 0) )
     4107    {
     4108      assume( p != NULL );
     4109      assume( nTerms > 0 );
     4110
     4111      // debug pring leading term
     4112      m_DebugPrint(p, lmRing);
     4113
     4114      poly q = pNext(p); // q = tail(p)
     4115
     4116      // debug pring tail (at most nTerms-1 terms from it)
     4117      for(int j = nTerms - 1; (q !=NULL) && (j > 0); pIter(q), --j)
     4118        m_DebugPrint(q, tailRing);
     4119
     4120      if (q != NULL)
     4121        PrintS("...\n");   
     4122    }
     4123  }
     4124  else
     4125    PrintS("0\n");         
     4126}
     4127
     4128
     4129
    37414130
    37424131/*2
     
    37914180
    37924181// for the time being, this is still here
    3793 static ring rAssure_SyzComp(ring r, BOOLEAN complete = TRUE);
    3794 
    3795 #define MYTEST 0
     4182static ring rAssure_SyzComp(const ring r, BOOLEAN complete = TRUE);
    37964183
    37974184ring rCurrRingAssure_SyzComp()
    37984185{
    3799 #ifdef HAVE_PLURAL
    38004186#if MYTEST
    38014187  PrintS("rCurrRingAssure_SyzComp(), currRing:  \n");
     
    38044190  rDebugPrint(currRing);
    38054191#endif
    3806 #endif
    3807 #endif
    3808 
    3809   ring r = rAssure_SyzComp(currRing);
    3810 
    3811   if (r != currRing)
    3812   {
    3813     ring old_ring = currRing;
     4192  PrintS("\n");
     4193#endif
     4194
     4195  ring r = rAssure_SyzComp(currRing, TRUE);
     4196
     4197  if( r != currRing )
     4198  {
    38144199    rChangeCurrRing(r);
    38154200    assume(currRing == r);
    38164201
    3817 #ifdef HAVE_PLURAL
    3818 #if MYTEST
    3819     PrintS("rCurrRingAssure_SyzComp(): currRing': ");
    3820     rWrite(currRing);
    3821 #ifdef RDEBUG
    3822     rDebugPrint(currRing);
    3823 #endif
    3824 #endif
    3825 #endif
    3826 
    3827 
    3828     if (old_ring->qideal != NULL)
    3829     {
    3830       r->qideal = idrCopyR_NoSort(old_ring->qideal, old_ring);
    3831       assume(idRankFreeModule(r->qideal) == 0);
    3832       currQuotient = r->qideal;
    3833 
    3834 #ifdef HAVE_PLURAL
    3835       if( rIsPluralRing(r) )
    3836         if( nc_SetupQuotient(r, old_ring, true) )
    3837         {
    3838 //          WarnS("error in nc_SetupQuotient"); // cleanup?      rDelete(res);       return r;  // just go on...?
    3839         }
    3840 #endif
    3841     }
    3842 
    3843 #ifdef HAVE_PLURAL
    3844     assume((r->qideal==NULL) == (old_ring->qideal==NULL));
    3845     assume(rIsPluralRing(r) == rIsPluralRing(old_ring));
    3846     assume(rIsSCA(r) == rIsSCA(old_ring));
    3847     assume(ncRingType(r) == ncRingType(old_ring));
    3848 #endif
    3849 
    3850   }
    3851 
    3852   assume(currRing == r);
    3853 
    3854 
    3855 #ifdef HAVE_PLURAL
    38564202#if MYTEST
    38574203  PrintS("\nrCurrRingAssure_SyzComp(): new currRing: \n");
     
    38604206  rDebugPrint(currRing);
    38614207#endif
    3862 #endif
    3863 #endif
     4208  PrintS("\n");
     4209#endif
     4210  }
    38644211
    38654212  return r;
    38664213}
    38674214
    3868 static ring rAssure_SyzComp(ring r, BOOLEAN complete)
    3869 {
    3870   if (r->order[0] == ringorder_s) return r;
     4215static ring rAssure_SyzComp(const ring r, BOOLEAN complete)
     4216{
     4217  if ( (r->order[0] == ringorder_s) ) return r;
     4218  if ( (r->order[0] == ringorder_IS) )
     4219  {
     4220    WarnS("rAssure_SyzComp in an IS ring!");
     4221//    return r;
     4222  }
    38714223  ring res=rCopy0(r, FALSE, FALSE);
    38724224  int i=rBlocks(r);
     
    39054257    assume(rIsPluralRing(r) == rIsPluralRing(res));
    39064258#endif
    3907   }
     4259
     4260
     4261#ifdef HAVE_PLURAL
     4262    ring old_ring = r;
     4263
     4264#if MYTEST
     4265    PrintS("rCurrRingAssure_SyzComp(): temp r': ");
     4266    rWrite(r);
     4267#ifdef RDEBUG
     4268    rDebugPrint(r);
     4269#endif
     4270    PrintS("\n");
     4271#endif
     4272#endif
     4273
     4274
     4275    if (r->qideal!=NULL)
     4276    {
     4277      res->qideal= idrCopyR_NoSort(r->qideal, r, res);
     4278
     4279      assume(idRankFreeModule(res->qideal, res) == 0);
     4280
     4281#ifdef HAVE_PLURAL
     4282      if( rIsPluralRing(res) )
     4283        if( nc_SetupQuotient(res, r, true) )
     4284        {
     4285//          WarnS("error in nc_SetupQuotient"); // cleanup?      rDelete(res);       return r;  // just go on...?
     4286        }
     4287
     4288#endif
     4289      assume(idRankFreeModule(res->qideal, res) == 0);
     4290    }
     4291
     4292#ifdef HAVE_PLURAL
     4293    assume((res->qideal==NULL) == (old_ring->qideal==NULL));
     4294    assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
     4295    assume(rIsSCA(res) == rIsSCA(old_ring));
     4296    assume(ncRingType(res) == ncRingType(old_ring));
     4297#endif
     4298
     4299#if MYTEST
     4300    PrintS("rCurrRingAssure_SyzComp(): res: ");
     4301    rWrite(r);
     4302#ifdef RDEBUG
     4303    rDebugPrint(r);
     4304#endif
     4305    PrintS("\n");
     4306#endif
     4307
     4308  }
     4309
    39084310  return res;
    39094311}
     
    39794381  if (r->qideal!=NULL)
    39804382  {
    3981      res->qideal=idrCopyR_NoSort(r->qideal,r);
     4383     res->qideal=idrCopyR_NoSort(r->qideal,r, res);
    39824384#ifdef HAVE_PLURAL
    39834385     if (rIsPluralRing(res))
     
    41204522          WarnS("error in nc_SetupQuotient"); // cleanup?      rDelete(res);       return r;  // just go on...?
    41214523        }
    4122       assume((new_r->qideal==NULL) == (old_r->qideal==NULL));
    4123       assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
    4124       assume(rIsSCA(new_r) == rIsSCA(old_r));
    4125       assume(ncRingType(new_r) == ncRingType(old_r));
    4126 #endif
    4127     }
     4524#endif
     4525    }
     4526
     4527#ifdef HAVE_PLURAL
     4528    assume((new_r->qideal==NULL) == (old_r->qideal==NULL));
     4529    assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
     4530    assume(rIsSCA(new_r) == rIsSCA(old_r));
     4531    assume(ncRingType(new_r) == ncRingType(old_r));
     4532#endif
     4533
    41284534    rTest(new_r);
    41294535    rTest(old_r);
     
    41324538}
    41334539
     4540// Moves _c or _C ordering to the last place AND adds _s on the 1st place
    41344541ring rCurrRingAssure_SyzComp_CompLastBlock()
    41354542{
    4136   ring new_r_1 = rAssure_CompLastBlock(currRing, FALSE);
    4137   ring new_r = rAssure_SyzComp(new_r_1, FALSE);
     4543  ring new_r_1 = rAssure_CompLastBlock(currRing, FALSE); // due to this FALSE - no completion!
     4544  ring new_r = rAssure_SyzComp(new_r_1, FALSE); // new_r_1 is used only here!!!
    41384545
    41394546  if (new_r != currRing)
     
    41644571          WarnS("error in nc_SetupQuotient"); // cleanup?      rDelete(res);       return r;  // just go on...?
    41654572        }
    4166       assume((new_r->qideal==NULL) == (old_r->qideal==NULL));
    4167       assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
    4168       assume(rIsSCA(new_r) == rIsSCA(old_r));
    4169       assume(ncRingType(new_r) == ncRingType(old_r));
    4170 #endif
    4171     }
     4573#endif
     4574    }
     4575
     4576#ifdef HAVE_PLURAL
     4577    assume((new_r->qideal==NULL) == (old_r->qideal==NULL));
     4578    assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
     4579    assume(rIsSCA(new_r) == rIsSCA(old_r));
     4580    assume(ncRingType(new_r) == ncRingType(old_r));
     4581#endif
     4582
    41724583    rTest(new_r);
    41734584    rTest(old_r);
     
    42154626
    42164627
     4628ring rAssure_InducedSchreyerOrdering(const ring r, BOOLEAN complete = TRUE, int sgn = 1)
     4629{ // TODO: ???? Add leading Syz-comp ordering here...????
     4630
     4631#if MYTEST
     4632    Print("rAssure_InducedSchreyerOrdering(r, complete = %d, sgn = %d): r: \n", complete, sgn);
     4633    rWrite(r);
     4634#ifdef RDEBUG
     4635    rDebugPrint(r);
     4636#endif
     4637    PrintS("\n");
     4638#endif
     4639
     4640
     4641  ring res=rCopy0(r, FALSE, FALSE); // No qideal & ordering copy.
     4642
     4643  int n = rBlocks(r); // Including trailing zero!
     4644
     4645  // Create 2 more blocks for prefix/suffix:
     4646  res->order=(int *)omAlloc0((n+2)*sizeof(int)); // 0  ..  n+1
     4647  res->block0=(int *)omAlloc0((n+2)*sizeof(int));
     4648  res->block1=(int *)omAlloc0((n+2)*sizeof(int));
     4649  int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
     4650
     4651  // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
     4652  // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
     4653
     4654  // new 1st block
     4655  int j = 0;
     4656  res->order[j] = ringorder_IS; // Prefix
     4657  // res->block0[j] = res->block1[j] = 0;
     4658  // wvhdl[j] = NULL;
     4659  j++;
     4660
     4661  for(int i = 0; (i <= n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
     4662  {
     4663    res->order [j] = r->order [i];
     4664    res->block0[j] = r->block0[i];
     4665    res->block1[j] = r->block1[i];
     4666
     4667    if (r->wvhdl[i] != NULL)
     4668    {
     4669      wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
     4670    } // else wvhdl[j] = NULL;
     4671  }
     4672
     4673  // new last block
     4674  res->order [j] = ringorder_IS; // Suffix
     4675  res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
     4676  // wvhdl[j] = NULL;
     4677  j++;
     4678
     4679  // res->order [j] = 0; // The End!
     4680  res->wvhdl = wvhdl;
     4681
     4682  // j == the last zero block now!
     4683  assume(j == (n+1));
     4684  assume(res->order[0]==ringorder_IS);
     4685  assume(res->order[j-1]==ringorder_IS);
     4686  assume(res->order[j]==0);
     4687
     4688
     4689  if (complete)
     4690  {
     4691    rComplete(res, 1);
     4692
     4693#if MYTEST
     4694    PrintS("rAssure_InducedSchreyerOrdering(): temp res: ");
     4695    rWrite(res);
     4696#ifdef RDEBUG
     4697    rDebugPrint(res);
     4698#endif
     4699    PrintS("\n");
     4700#endif
     4701
     4702
     4703
     4704#ifdef HAVE_PLURAL
     4705    if (rIsPluralRing(r))
     4706    {
     4707      if ( nc_rComplete(r, res, false) ) // no qideal!
     4708      {
     4709        WarnS("error in nc_rComplete");      // cleanup?//      rDelete(res);//      return r;      // just go on..
     4710      }
     4711    }
     4712    assume(rIsPluralRing(r) == rIsPluralRing(res));
     4713#endif
     4714
     4715
     4716#ifdef HAVE_PLURAL
     4717    ring old_ring = r;
     4718
     4719#if MYTEST
     4720    PrintS("rAssure_InducedSchreyerOrdering(): temp nc res: ");
     4721    rWrite(res);
     4722#ifdef RDEBUG
     4723    rDebugPrint(res);
     4724#endif
     4725    PrintS("\n");
     4726#endif
     4727#endif
     4728
     4729
     4730    if (r->qideal!=NULL)
     4731    {
     4732      res->qideal= idrCopyR_NoSort(r->qideal, r, res);
     4733
     4734      assume(idRankFreeModule(res->qideal, res) == 0);
     4735
     4736#ifdef HAVE_PLURAL
     4737      if( rIsPluralRing(res) )
     4738        if( nc_SetupQuotient(res, r, true) )
     4739        {
     4740//          WarnS("error in nc_SetupQuotient"); // cleanup?      rDelete(res);       return r;  // just go on...?
     4741        }
     4742
     4743#endif
     4744      assume(idRankFreeModule(res->qideal, res) == 0);
     4745    }
     4746
     4747#ifdef HAVE_PLURAL
     4748    assume((res->qideal==NULL) == (old_ring->qideal==NULL));
     4749    assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
     4750    assume(rIsSCA(res) == rIsSCA(old_ring));
     4751    assume(ncRingType(res) == ncRingType(old_ring));
     4752#endif
     4753  }
     4754
     4755  return res;
     4756}
     4757
     4758
     4759
     4760
     4761
    42174762ring rCurrRingAssure_dp_S()
    42184763{
     
    42284773{
    42294774  return rCurrRingAssure_Global(ringorder_C, ringorder_dp);
     4775}
     4776
     4777/// Changes r by setting induced ordering parameters: limit and reference leading terms
     4778/// F belong to r, we will DO a copy! (same to componentWeights)
     4779/// We will use it AS IS!
     4780/// returns true is everything was allright!
     4781bool rSetISReference(const ideal F, const int i = 0, const int p = 0, const intvec * componentWeights = NULL, const ring r = currRing)
     4782{
     4783  // Put the reference set F into the ring -ordering -recor
     4784#if MYTEST
     4785  Print("rSetISReference(F, i: %d, p: %d, w)\nF:", i, p);
     4786  idShow(F, r, r, 1); // currRing!
     4787  PrintLn();
     4788  PrintS("w: ");
     4789  if(componentWeights == NULL)
     4790    PrintS("NULL\n");
     4791  else
     4792    componentWeights->show();
     4793#endif
     4794
     4795  // TEST THAT THERE ARE DEGs!!!
     4796  // assume( componentWeights == NULL  ); // ???
     4797  if( componentWeights != NULL )
     4798  {
     4799//    assure that the ring r has degrees!!!
     4800//    Add weights to degrees of F[i]
     4801  }
     4802
     4803  if (r->typ==NULL)
     4804  {
     4805    dReportError("Error: WRONG USE of rSetISReference: wrong ring! (typ == NULL)");
     4806    return false;
     4807  }
     4808
     4809  int j = p; // Which IS record to use...
     4810  for( int pos = 0; pos < r->OrdSize; pos++ )
     4811    if( r->typ[pos].ord_typ == ro_is)
     4812      if( j-- == 0 )
     4813      {
     4814#if MYTEST
     4815        Print("Changing record on pos: %d\nOld limit: %d --->> New Limit: %d\n", pos, r->typ[pos].data.is.limit, i);
     4816#endif
     4817
     4818        const ideal FF = idrHeadR(F, r, r);
     4819
     4820
     4821        if( r->typ[pos].data.is.F != NULL)
     4822        {
     4823#if MYTEST
     4824          PrintS("Deleting old reference set F... \n");        // idShow(r->typ[pos].data.is.F, r);         PrintLn();
     4825#endif
     4826          id_Delete(&r->typ[pos].data.is.F, r);
     4827          r->typ[pos].data.is.F = NULL;
     4828        }
     4829
     4830        assume(r->typ[pos].data.is.F == NULL);
     4831
     4832       
     4833        r->typ[pos].data.is.F = FF; // F is owened by ring now! TODO: delete at the end!
     4834
     4835        if(r->typ[pos].data.is.componentWeights != NULL)
     4836        {
     4837#if MYTEST
     4838          PrintS("Deleting old componentWeights: "); r->typ[pos].data.is.componentWeights->show(); PrintLn();
     4839#endif
     4840          delete r->typ[pos].data.is.componentWeights;
     4841          r->typ[pos].data.is.componentWeights = NULL;
     4842        }
     4843
     4844
     4845        assume(r->typ[pos].data.is.componentWeights == NULL);
     4846
     4847        if( componentWeights != NULL )
     4848          componentWeights = ivCopy(componentWeights); // componentWeights is owened by ring now! TODO: delete at the end!
     4849
     4850        r->typ[pos].data.is.componentWeights = componentWeights;
     4851
     4852        r->typ[pos].data.is.limit = i; // First induced component
     4853
     4854#if MYTEST
     4855        PrintS("New reference set FF : \n");        idShow(FF, r, r, 1);         PrintLn();
     4856#endif
     4857
     4858        return true;
     4859      }
     4860
     4861  dReportError("Error: WRONG USE of rSetISReference: specified ordering block was not found!!!" );
     4862  return false;
    42304863}
    42314864
     
    42584891    currRing->typ[0].data.syz.limit = k;
    42594892    currRing->typ[0].data.syz.curr_index++;
    4260   }
    4261   else if ((currRing->order[0]!=ringorder_c) && (k!=0))
     4893     
     4894  } else if(
     4895            (currRing->typ!=NULL) &&
     4896            (currRing->typ[0].ord_typ==ro_isTemp)
     4897           )
     4898  {
     4899//      (currRing->typ[currRing->typ[0].data.isTemp.suffixpos].data.is.limit == k)
     4900    Warn("rSetSyzComp(%d) in an IS ring! Be careful!", k);
     4901  } else
     4902  if ((currRing->order[0]!=ringorder_c) && (k!=0)) // ???
    42624903  {
    42634904    dReportError("syzcomp in incompatible ring");
     
    46135254      // should not occur:
    46145255      case ringorder_S:
     5256      case ringorder_IS:
    46155257      case ringorder_s:
    46165258      case ringorder_aa:
     
    46915333  if (src->qideal != NULL)
    46925334  {
    4693     idDelete(&(r->qideal));
     5335    id_Delete(&(r->qideal), r);
    46945336
    46955337#ifdef HAVE_PLURAL
  • kernel/ring.h

    r45c67dc r645a19  
    77* ABSTRACT - the interpreter related ring operations
    88*/
    9 /* $Id: ring.h,v 1.41 2009-05-06 12:53:49 Singular Exp $ */
     9/* $Id: ring.h,v 1.42 2009-07-20 12:00:51 motsak Exp $ */
    1010
    1111/* includes */
     
    2828void   rKill(ring r);
    2929ring   rCopy(ring r);
    30 ring rCopy0(ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE);
     30ring   rCopy0(const ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE);
    3131void   rNameCheck(ring R);
    3232ring   rOpposite(ring r);
    3333ring   rEnvelope(ring r);
    3434
    35 // we must always have this test!
     35/// we must always have this test!
    3636inline bool rIsPluralRing(const ring r)
    3737{
     
    248248n_coeffType rFieldType(ring r);
    249249
    250 // this needs to be called whenever a new ring is created: new fields
    251 // in ring are created (like VarOffset), unless they already exist
    252 // with force == 1, new fields are _always_ created (overwritten),
    253 // even if they exist
     250/// this needs to be called whenever a new ring is created: new fields
     251/// in ring are created (like VarOffset), unless they already exist
     252/// with force == 1, new fields are _always_ created (overwritten),
     253/// even if they exist
    254254BOOLEAN rComplete(ring r, int force = 0);
    255 // use this to free fields created by rComplete
     255// use this to free fields created by rComplete //?
    256256
    257257inline int rBlocks(ring r)
     
    276276}
    277277
    278 // order stuff
     278/// order stuff
    279279typedef enum rRingOrder_t
    280280{
    281281  ringorder_no = 0,
    282282  ringorder_a,
    283   ringorder_a64, // for int64 weights
     283  ringorder_a64, ///< for int64 weights
    284284  ringorder_c,
    285285  ringorder_C,
    286286  ringorder_M,
    287   ringorder_S,
    288   ringorder_s,
     287  ringorder_S, ///< S?
     288  ringorder_s, ///< s?
    289289  ringorder_lp,
    290290  ringorder_dp,
     
    300300  ringorder_L,
    301301  // the following are only used internally
    302   ringorder_aa, // for idElimination, like a, except pFDeg, pWeigths ignore it
    303   ringorder_rs,
     302  ringorder_aa, ///< for idElimination, like a, except pFDeg, pWeigths ignore it
     303  ringorder_rs, ///< ???
     304  ringorder_IS, ///< Induced (Schreyer) ordering
    304305  ringorder_unspec
    305306} rRingOrder_t;
     
    307308typedef enum rOrderType_t
    308309{
    309   rOrderType_General = 0, // non-simple ordering as specified by currRing
    310   rOrderType_CompExp,     // simple ordering, component has priority
    311   rOrderType_ExpComp,     // simple ordering, exponent vector has priority
    312                           // component not compatible with exp-vector order
    313   rOrderType_Exp,         // simple ordering, exponent vector has priority
    314                           // component is compatible with exp-vector order
    315   rOrderType_Syz,         // syzygy ordering
    316   rOrderType_Schreyer,    // Schreyer ordering
    317   rOrderType_Syz2dpc,     // syzcomp2dpc
    318   rOrderType_ExpNoComp    // simple ordering, differences in component are
    319                           // not considered
     310  rOrderType_General = 0, ///< non-simple ordering as specified by currRing
     311  rOrderType_CompExp,     ///< simple ordering, component has priority
     312  rOrderType_ExpComp,     ///< simple ordering, exponent vector has priority
     313                          ///< component not compatible with exp-vector order
     314  rOrderType_Exp,         ///< simple ordering, exponent vector has priority
     315                          ///< component is compatible with exp-vector order
     316  rOrderType_Syz,         ///< syzygy ordering
     317  rOrderType_Schreyer,    ///< Schreyer ordering
     318  rOrderType_Syz2dpc,     ///< syzcomp2dpc
     319  rOrderType_ExpNoComp    ///< simple ordering, differences in component are
     320                          ///< not considered
    320321} rOrderType_t;
    321322
    322 inline BOOLEAN rIsSyzIndexRing(ring r)
     323inline BOOLEAN rIsSyzIndexRing(const ring r)
    323324{ return r->order[0] == ringorder_s;}
    324325
    325 inline int rGetCurrSyzLimit(ring r = currRing)
    326 { return (r->order[0] == ringorder_s ?
    327           r->typ[0].data.syz.limit : 0);}
     326inline int rGetCurrSyzLimit(const ring r = currRing)
     327{ return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}
    328328
    329329// Ring Manipulations
     
    334334ring   rCurrRingAssure_dp_C();
    335335ring   rCurrRingAssure_C_dp();
    336 // makes sure that c/C ordering is last ordering
     336
     337/// makes sure that c/C ordering is last ordering
    337338ring   rCurrRingAssure_CompLastBlock();
    338 // makes sure that c/C ordering is last ordering and SyzIndex is first
     339
     340/// makes sure that c/C ordering is last ordering and SyzIndex is first
    339341ring   rCurrRingAssure_SyzComp_CompLastBlock();
    340342ring rAssure_TDeg(ring r, int start_var, int end_var, int &pos);
    341343
    342 // return the max-comonent wchich has syzIndex i
    343 // Assume: i<= syzIndex_limit
     344/// return the max-comonent wchich has syzIndex i
     345/// Assume: i<= syzIndex_limit
    344346int rGetMaxSyzComp(int i);
    345347
    346348BOOLEAN rHasSimpleOrder(const ring r);
    347 // returns TRUE, if simple lp or ls ordering
     349
     350/// returns TRUE, if simple lp or ls ordering
    348351BOOLEAN rHasSimpleLexOrder(const ring r);
     352
    349353// return TRUE if p->exp[r->pOrdIndex] holds total degree of p */
    350354//inline BOOLEAN rHasGlobalOrdering(const ring r=currRing)
     
    357361#define rHasLocalOrMixedOrdering_currRing() (pOrdSgn==-1)
    358362BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing);
    359 // return TRUE if p_SetComp requires p_Setm
     363
     364/// return TRUE if p_SetComp requires p_Setm
    360365BOOLEAN rOrd_SetCompRequiresSetm(ring r);
    361366rOrderType_t    rGetOrderType(ring r);
    362 /* returns TRUE if var(i) belongs to p-block */
     367
     368/// returns TRUE if var(i) belongs to p-block
    363369BOOLEAN rIsPolyVar(int i, ring r = currRing);
    364370
     
    380386                         BOOLEAN omit_comp,
    381387                         unsigned long exp_limit);
    382 // construct Wp, C ring
     388
     389/// construct Wp, C ring
    383390ring rModifyRing_Wp(ring r, int* weights);
    384391void rModify_a_to_A(ring r);
     
    391398void rKillModifiedRing_Simple(ring r);
    392399
     400#ifdef RDEBUG
    393401void rDebugPrint(ring r);
    394402void pDebugPrint(poly p);
    395403void p_DebugPrint(poly p, const ring r);
     404#endif
     405
     406/// debug-print at most nTerms (2 by default) terms from poly/vector p,
     407/// assuming that lt(p) lives in lmRing and tail(p) lives in tailRing.
     408void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms = 2);
    396409
    397410int64 * rGetWeightVec(ring r);
  • kernel/structs.h

    r45c67dc r645a19  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: structs.h,v 1.61 2009-05-29 16:21:04 Singular Exp $ */
     6/* $Id: structs.h,v 1.62 2009-07-20 12:00:51 motsak Exp $ */
    77/*
    88* ABSTRACT
     
    356356             // with possibly negative weights
    357357  ro_cp,    // ordering duplicates variables
    358   ro_syzcomp, // ordering indicates "subset" of component number
    359   ro_syz, // ordering  with component number >syzcomp is lower
     358  ro_syzcomp, // ordering indicates "subset" of component number (ringorder_S)
     359  ro_syz, // ordering  with component number >syzcomp is lower (ringorder_s)
     360  ro_isTemp, ro_is, // Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS)
    360361  ro_none
    361362}
     
    422423
    423424typedef struct sro_syz sro_syz;
     425// Induced Syzygy (Schreyer) ordering is built inductively as follows:
     426// we look for changes made by ordering blocks which are between prefix/suffix markers:
     427// that is: which variables where placed by them and where (judging by v)
     428
     429// due to prefix/suffix nature we need some placeholder:
     430// prefix stores here initial state
     431// suffix cleares this up
     432struct sro_ISTemp
     433{
     434  short start; // 1st member SHOULD be short "place"
     435  int   suffixpos;
     436  int*  pVarOffset; // copy!
     437};
     438
     439// So this is the actuall thing!
     440// suffix uses last sro_ISTemp (cleares it up afterwards) and
     441// creates this block
     442struct sro_IS
     443{
     444  short start, end;  // which part of L we want to want to update...
     445  int*  pVarOffset; // same as prefix!
     446
     447  int limit; // first referenced component
     448
     449  // reference poly set?? // Should it be owned by ring?!!!
     450  ideal F; // reference leading (module)-monomials set. owned by ring...
     451  const intvec* componentWeights; // component weights! owned by ring...
     452};
     453
     454typedef struct sro_IS sro_IS;
     455typedef struct sro_ISTemp sro_ISTemp;
    424456
    425457#ifndef OM_ALLOC_H
     
    439471     sro_syzcomp syzcomp;
    440472     sro_syz syz;
     473     sro_IS is;
     474     sro_ISTemp isTemp;
    441475  } data;
    442476};
     
    631665  BOOLEAN   ShortOut;
    632666  BOOLEAN   CanShortOut;
    633   BOOLEAN   LexOrder;
    634   // TRUE if the monomial ordering has polynomial and power series blocks
    635   BOOLEAN   MixedOrder;
    636   // TRUE for global/local mixed orderings, FALSE otherwise
    637   BOOLEAN   ComponentOrder;
     667  BOOLEAN   LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
     668  BOOLEAN   MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise
     669
     670  BOOLEAN   ComponentOrder; // ???
    638671
    639672
Note: See TracChangeset for help on using the changeset viewer.