Changeset 645a19 in git
- Timestamp:
- Jul 20, 2009, 2:01:13 PM (14 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ba3e3ef698fa0b7c5867199959cc83330073d3cb')
- Children:
- 195b03db00f5e08ad6a891adcf3a7794a5dd00bf
- Parents:
- 45c67dc7a3eec0097d1ad6ff5635d960cc089937
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/extra.cc
r45c67dc r645a19 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.30 7 2009-07-16 08:12:26 edercExp $ */4 /* $Id: extra.cc,v 1.308 2009-07-20 12:01:13 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 88 88 #endif 89 89 90 #include "attrib.h" 91 90 92 #if defined(HPUX_10) || defined(HPUX_9) 91 93 extern "C" int setenv(const char *name, const char *value, int overwrite); … … 197 199 leftv h=args->next; 198 200 // ONLY documented system calls go here 199 // Undocumented system calls go down into #ifdef HAVE_EXTENDED_SYSTEM201 // Undocumented system calls go down into jjEXTENDED_SYSTEM (#ifdef HAVE_EXTENDED_SYSTEM) 200 202 /*==================== nblocks ==================================*/ 201 203 if (strcmp(sys_cmd, "nblocks") == 0) … … 725 727 726 728 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 727 815 #ifdef HAVE_PLURAL 728 816 /*==================== Approx_Step =================*/ … … 1970 2058 } 1971 2059 else 2060 /*==================== poly debug ==================================*/ 2061 if(strcmp(sys_cmd,"p")==0) 2062 { 1972 2063 #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 1980 2069 /*==================== 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 1988 2106 /*==================== mtrack ==================================*/ 1989 2107 if(strcmp(sys_cmd,"mtrack")==0) … … 2589 2707 { 2590 2708 WerrorS("ideal expected"); 2591 return false;2709 return TRUE; 2592 2710 } 2593 2711 … … 2604 2722 res->rtyp=IDEAL_CMD; 2605 2723 res->data=(ideal) F5main(G,r,opt); 2606 return false;2724 return FALSE; 2607 2725 } 2608 2726 else … … 2615 2733 { 2616 2734 WerrorS("ideal expected"); 2617 return false;2735 return TRUE; 2618 2736 } 2619 2737 … … 2622 2740 res->rtyp=IDEAL_CMD; 2623 2741 res->data=(ideal) f5cMain(G,r); 2624 return false;2742 return FALSE; 2625 2743 } 2626 2744 else -
kernel/ideals.cc
r45c67dc r645a19 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1.7 4 2009-06-04 08:14:57 SingularExp $ */4 /* $Id: ideals.cc,v 1.75 2009-07-20 12:00:50 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 9 9 /* includes */ 10 10 #include "mod2.h" 11 12 #ifndef NDEBUG 13 # define MYTEST 0 14 #else /* ifndef NDEBUG */ 15 # define MYTEST 0 16 #endif /* ifndef NDEBUG */ 17 11 18 #include "structs.h" 12 19 #include "omalloc.h" … … 26 33 27 34 28 #define MYTEST 029 35 30 36 … … 66 72 //#ifndef __OPTIMIZE__ 67 73 // this is mainly for outputting an ideal within the debugger 68 void idShow(ideal id) 69 { 74 void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint) 75 { 76 assume( debugPrint >= 0 ); 77 70 78 if( id == NULL ) 71 79 Print("(NULL)"); … … 73 81 { 74 82 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); 82 90 } 83 91 } … … 1323 1331 Print("Prepare::h2: "); 1324 1332 idPrint(h2); 1333 1334 for(j=0;j<IDELEMS(h2);j++) pTest(h2->m[j]); 1335 1325 1336 #endif 1326 1337 #endif … … 1356 1367 #endif 1357 1368 1369 idTest(h2); 1358 1370 1359 1371 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 1360 1382 idDelete(&h2); 1361 1383 return h3; … … 1377 1399 int ii, idElemens_h1; 1378 1400 1401 assume(h1 != NULL); 1402 1379 1403 idElemens_h1=IDELEMS(h1); 1380 1404 #ifdef PDEBUG … … 1412 1436 } 1413 1437 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 1415 1441 1416 1442 if (s_h3==NULL) … … 1589 1615 #if MYTEST 1590 1616 #ifdef RDEBUG 1591 Print(" Input: ");1617 Print("idLiftStd Input: "); 1592 1618 idPrint(s_h1); 1593 1619 #endif … … 1599 1625 #if MYTEST 1600 1626 #ifdef RDEBUG 1601 Print(" Prepare: ");1627 Print("idLiftStd Prepare: "); 1602 1628 idPrint(s_h3); 1603 1629 #endif … … 1608 1634 #if MYTEST 1609 1635 #ifdef RDEBUG 1610 Print(" Temp: ");1636 Print("idLiftStd Temp: "); 1611 1637 idPrint(s_h2); 1612 1638 #endif … … 1646 1672 #if MYTEST 1647 1673 #ifdef RDEBUG 1648 Print(" Input'': ");1674 Print("idLiftStd Input'': "); 1649 1675 idPrint(s_h3); 1650 1676 #endif … … 1656 1682 #if MYTEST 1657 1683 #ifdef RDEBUG 1658 Print(" Temp Result: ");1684 Print("idLiftStd Temp Result: "); 1659 1685 idPrint(s_h2); 1660 1686 #endif … … 1701 1727 #if MYTEST 1702 1728 #ifdef RDEBUG 1703 Print(" Output STD Ideal: ");1729 Print("idLiftStd Output STD Ideal: "); 1704 1730 idPrint(s_h3); 1705 1731 1706 Print(" Output Matrix: ");1732 Print("idLiftStd Output Matrix: "); 1707 1733 iiWriteMatrix(*ma, "ma", 2, 4); 1708 1734 #endif -
kernel/ideals.h
r45c67dc r645a19 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: ideals.h,v 1.1 3 2009-02-12 16:19:23motsak Exp $ */6 /* $Id: ideals.h,v 1.14 2009-07-20 12:00:50 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate ideals … … 22 22 void id_ShallowDelete (ideal* h, ring r); 23 23 /* Shows an ideal -- mainly for debugging */ 24 void idShow( ideal id);24 void idShow(const ideal id, const ring lmRing = currRing, const ring tailRing = currRing, const int debugPrint = 0); 25 25 /*- initialise an ideal -*/ 26 26 ideal idMaxIdeal (int deg); -
kernel/kstd1.cc
r45c67dc r645a19 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd1.cc,v 1.5 5 2009-07-17 11:31:10 SingularExp $ */4 /* $Id: kstd1.cc,v 1.56 2009-07-20 12:00:50 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: 7 7 */ 8 8 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 9 14 // define if buckets should be used 10 15 #define MORA_USE_BUCKETS 11 16 12 // define if tailrings should be used13 #define HAVE_TAIL_RING14 15 17 #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 16 31 #include "structs.h" 17 32 #include "omalloc.h" … … 1683 1698 int newIdeal, intvec *vw) 1684 1699 { 1700 if(idIs0(F)) 1701 return idInit(1,F->rank); 1702 1685 1703 ideal r; 1686 1704 BOOLEAN b=pLexOrder,toReset=FALSE; … … 1743 1761 #ifdef KDEBUG 1744 1762 idTest(F); 1763 idTest(Q); 1764 1765 #if MYTEST 1766 PrintS("kSTD: currRing: "); rWrite(currRing); 1767 #endif 1768 1745 1769 #endif 1746 1770 #ifdef HAVE_PLURAL … … 1891 1915 int syzComp, int reduced) 1892 1916 { 1917 if(idIs0(F)) 1918 return idInit(1,F->rank); 1919 1893 1920 ideal r=NULL; 1894 1921 int Kstd1_OldDeg = Kstd1_deg,i; … … 2017 2044 if (p==NULL) 2018 2045 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 2019 2061 if ((idIs0(F))&&(Q==NULL)) 2062 { 2063 #ifdef HAVE_PLURAL 2064 if(p != pp) 2065 return pp; 2066 #endif 2020 2067 return pCopy(p); /*F+Q=0*/ 2068 } 2069 2070 2021 2071 kStrategy strat=new skStrategy; 2022 2072 strat->syzComp = syzComp; 2023 2073 strat->ak = si_max(idRankFreeModule(F),pMaxComp(p)); 2024 2074 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 2038 2076 2039 2077 poly res; … … 2062 2100 if (idIs0(p)) 2063 2101 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 2064 2117 if ((idIs0(F))&&(Q==NULL)) 2118 { 2119 #ifdef HAVE_PLURAL 2120 if(p != pp) 2121 return pp; 2122 #endif 2123 2065 2124 return idCopy(p); /*F+Q=0*/ 2125 } 2066 2126 2067 2127 kStrategy strat=new skStrategy; … … 2069 2129 strat->ak = si_max(idRankFreeModule(F),idRankFreeModule(p)); 2070 2130 2071 ideal pp = p;2072 #ifdef HAVE_PLURAL2073 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 #endif2083 2131 2084 2132 if (pOrdSgn==-1) -
kernel/kstd2.cc
r45c67dc r645a19 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1.9 8 2009-07-17 09:51:42 SingularExp $ */4 /* $Id: kstd2.cc,v 1.99 2009-07-20 12:00:51 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 8 8 9 9 // #define PDEBUG 2 10 11 // TODO: why the following is here instead of mod2.h??? 12 10 13 // define to enable tailRings 11 14 #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 12 30 // define if no buckets should be used 13 31 // #define NO_BUCKETS 14 32 15 #include "mod2.h"16 33 #ifdef HAVE_PLURAL 17 34 #define PLURAL_INTERNAL_DECLARATIONS 1 … … 946 963 #ifdef KDEBUG 947 964 static int bba_count = 0; 948 #endif 965 #endif /* KDEBUG */ 949 966 void kDebugPrint(kStrategy strat); 950 967 … … 954 971 bba_count++; 955 972 int loop_count = 0; 956 #endif 973 #endif /* KDEBUG */ 957 974 om_Opts.MinTrack = 5; 958 975 int srmax,lrmax, red_result = 1; … … 983 1000 kTest_TS(strat); 984 1001 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 985 1016 #ifdef HAVE_TAIL_RING 986 kStratInitChangeTailRing(strat); 1017 if(!idIs0(F)) 1018 kStratInitChangeTailRing(strat); 987 1019 #endif 988 1020 if (BVERBOSE(23)) … … 1093 1125 int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); 1094 1126 1127 #ifdef KDEBUG 1128 #if MYTEST 1129 PrintS("New S: "); pDebugPrint(strat->P.p); PrintLn(); 1130 #endif /* MYTEST */ 1131 #endif /* KDEBUG */ 1132 1095 1133 // reduce the tail and normalize poly 1096 1134 // in the ring case we cannot expect LC(f) = 1, … … 1114 1152 #ifdef KDEBUG 1115 1153 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 */ 1117 1158 1118 1159 // min_std stuff … … 1185 1226 #ifdef KDEBUG 1186 1227 memset(&(strat->P), 0, sizeof(strat->P)); 1187 #endif 1228 #endif /* KDEBUG */ 1188 1229 kTest_TS(strat); 1189 1230 } 1190 1231 #ifdef KDEBUG 1232 #if MYTEST 1233 PrintS("bba finish GB: currRing: "); rWrite(currRing); 1234 #endif /* MYTEST */ 1191 1235 if (TEST_OPT_DEBUG) messageSets(strat); 1192 #endif 1236 #endif /* KDEBUG */ 1237 1193 1238 if (TEST_OPT_SB_1) 1194 1239 { … … 1240 1285 if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat); 1241 1286 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 1242 1295 return (strat->Shdl); 1243 1296 } … … 1246 1299 { 1247 1300 assume(q!=NULL); 1248 assume(!(idIs0(F)&&(Q==NULL))); 1301 assume(!(idIs0(F)&&(Q==NULL))); // NF(q, std(0) in polynomial ring? 1249 1302 1250 1303 // lazy_reduce flags: can be combined by | -
kernel/kutil.cc
r45c67dc r645a19 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.14 7 2009-07-10 15:13:56 SingularExp $ */4 /* $Id: kutil.cc,v 1.148 2009-07-20 12:00:51 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 13 13 #include <string.h> 14 14 #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 15 23 #include <mylimits.h> 16 24 #include "structs.h" … … 1393 1401 pSetm(Lp.lcm); 1394 1402 1395 #define MYTEST 01396 1403 1397 1404 if (strat->sugarCrit && ALLOW_PROD_CRIT(strat)) … … 6239 6246 BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject* T, unsigned long expbound) 6240 6247 { 6248 assume(strat->tailRing == currRing); 6249 6241 6250 if (expbound == 0) expbound = strat->tailRing->bitmask << 1; 6242 6251 if (expbound >= currRing->bitmask) return FALSE; … … 6248 6257 (strat->homog && pFDeg == pDeg && !(rField_is_Ring(currRing))), // TODO Oliver 6249 6258 #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 6254 6264 if (new_tailRing == currRing) return TRUE; 6255 6265 … … 6341 6351 int i; 6342 6352 Exponent_t e; 6343 ring new_tailRing; 6353 // ring new_tailRing; // What for??? 6344 6354 6345 6355 assume(strat->tailRing == currRing); -
kernel/pInline2.h
r45c67dc r645a19 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: pInline2.h,v 1.1 6 2009-05-29 13:57:35motsak Exp $9 * Version: $Id: pInline2.h,v 1.17 2009-07-20 12:00:51 motsak Exp $ 10 10 *******************************************************************/ 11 11 #ifndef PINLINE2_H … … 50 50 return (((long)((p)->exp[r->pOrdIndex]))-POLY_NEGWEIGHT_OFFSET); 51 51 case ro_syzcomp: 52 case ro_syz: 52 case ro_syz: case ro_isTemp: case ro_is: 53 53 case ro_cp: 54 54 i++; … … 75 75 return (p)->exp[r->pOrdIndex]=o+POLY_NEGWEIGHT_OFFSET; 76 76 case ro_syzcomp: 77 case ro_syz: 77 case ro_syz: case ro_isTemp: case ro_is: 78 78 case ro_cp: 79 79 i++; … … 197 197 // 1, 2, 3 - anything like 00011..11 198 198 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 205 205 PINLINE2 int p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset) 206 206 { -
kernel/p_polys.cc
r45c67dc r645a19 7 7 * Author: obachman (Olaf Bachmann) 8 8 * Created: 8/00 9 * Version: $Id: p_polys.cc,v 1.1 7 2009-06-10 15:34:50 SingularExp $9 * Version: $Id: p_polys.cc,v 1.18 2009-07-20 12:00:51 motsak Exp $ 10 10 *******************************************************************/ 11 11 … … 173 173 break; 174 174 } 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 } 175 320 default: 176 321 dReportError("wrong ord in rSetm:%d\n",o->ord_typ); … … 337 482 case ringorder_S: 338 483 case ringorder_s: 484 case ringorder_IS: 339 485 case ringorder_aa: 340 486 break; -
kernel/ring.cc
r45c67dc r645a19 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.12 2 2009-07-10 15:13:57 SingularExp $ */4 /* $Id: ring.cc,v 1.123 2009-07-20 12:00:51 motsak Exp $ */ 5 5 6 6 /* … … 11 11 #include <math.h> 12 12 #include "mod2.h" 13 14 #ifndef NDEBUG 15 # define MYTEST 0 16 #else /* ifndef NDEBUG */ 17 # define MYTEST 0 18 #endif /* ifndef NDEBUG */ 19 13 20 #include "structs.h" 14 21 #include "omalloc.h" … … 38 45 static const char * const ringorder_name[] = 39 46 { 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 63 71 }; 64 72 … … 68 76 } 69 77 70 // unconditionally deletes fields in r78 /// unconditionally deletes fields in r 71 79 void rDelete(ring r); 72 // set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex80 /// set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex 73 81 static void rSetVarL(ring r); 74 // get r->divmask depending on bits per exponent82 /// get r->divmask depending on bits per exponent 75 83 static unsigned long rGetDivMask(int bits); 76 // right-adjust r->VarOffset84 /// right-adjust r->VarOffset 77 85 static void rRightAdjustVarOffset(ring r); 78 86 static void rOptimizeLDeg(ring r); … … 88 96 //} 89 97 90 // internally changes the gloabl ring and resets the relevant91 // global variables:98 /// internally changes the gloabl ring and resets the relevant 99 /// global variables: 92 100 void rChangeCurrRing(ring r) 93 101 { … … 358 366 Print("ordering %s", rSimpleOrdStr(r->order[l])); 359 367 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) 361 389 ||(r->order[l] == ringorder_M) 362 390 ||(r->order[l] == ringorder_a) 363 391 ||(r->order[l] == ringorder_a64) 364 ||(r->order[l] == ringorder_aa) )392 ||(r->order[l] == ringorder_aa) ) && (r->order[l] < ringorder_IS) ) 365 393 { 366 394 PrintS("\n// : names "); … … 371 399 } 372 400 } 373 #ifndef NDEBUG374 else if (r->order[l] == ringorder_s)375 {376 Print(" syzcomp at %d",r->typ[l].data.syz.limit);377 }378 #endif379 401 380 402 if (r->wvhdl[l]!=NULL) … … 391 413 int64 *w=(int64 *)r->wvhdl[l]; 392 414 #if SIZEOF_LONG == 4 393 Print(" %*lld" ,nlen,w[i+j],i+j);415 Print("%*lld " ,nlen,w[i+j],i+j); 394 416 #else 395 417 Print(" %*ld" ,nlen,w[i+j],i+j); … … 1483 1505 * DOES NOT CALL rComplete 1484 1506 */ 1485 ring rCopy0( ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)1507 ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering) 1486 1508 { 1487 1509 if (r == NULL) return NULL; … … 1623 1645 if (r->qideal!=NULL) 1624 1646 { 1625 if (copy_qideal) res->qideal= idrCopyR_NoSort(r->qideal, r );1647 if (copy_qideal) res->qideal= idrCopyR_NoSort(r->qideal, r, res); 1626 1648 //memset: else res->qideal = NULL; 1627 1649 } … … 1928 1950 { 1929 1951 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; 1931 1953 } 1932 1954 } … … 2037 2059 omCheckAddrSize(r->VarOffset,(r->N+1)*sizeof(*(r->VarOffset))); 2038 2060 // test assumptions: 2039 for(i=0;i<=r->N;i++) 2061 for(i=0;i<=r->N;i++) // for all variables (i = 0..N) 2040 2062 { 2041 2063 if(r->typ!=NULL) 2042 2064 { 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 } 2054 2106 } 2055 2107 } … … 2327 2379 } 2328 2380 2381 2382 static 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 } 2409 static 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 2329 2512 static unsigned long rGetExpSize(unsigned long bitmask, int & bits) 2330 2513 { … … 2447 2630 } 2448 2631 } 2632 2633 2634 bool rSetISReference(const ideal F, const int i, const int p, const intvec * componentWeights, const ring r); 2635 2449 2636 2450 2637 /*2 … … 2462 2649 BOOLEAN need_other_ring; 2463 2650 BOOLEAN omitted_degree = FALSE; 2651 2652 int iNeedInducedOrderingSetup = 0; ///< How many induced ordering block do we have? 2464 2653 int bits; 2465 2654 … … 2475 2664 int i=0; 2476 2665 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]) 2478 2668 { 2479 2669 BOOLEAN copy_block_index=TRUE; 2480 int r_ord=r->order[i]; 2670 2481 2671 if (r->block0[i]==r->block1[i]) 2482 2672 { … … 2501 2691 switch(r_ord) 2502 2692 { 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 } 2503 2699 case ringorder_C: 2504 2700 case ringorder_c: … … 2547 2743 } 2548 2744 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 } 2549 2767 default: 2550 2768 order[j]=r_ord; /*r->order[i];*/ … … 2557 2775 wvhdl[j]=r->wvhdl[i]; 2558 2776 } 2559 i++;j++; 2777 2560 2778 // order[j]=ringorder_no; // done by omAlloc0 2561 if (i==nblocks) break;2562 2779 } 2563 2780 if(!need_other_ring) … … 2603 2820 2604 2821 // 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! ... 2615 2855 } 2616 2856 // the special case: homog (omit_degree) and 1 block rs: that is global: … … 2631 2871 2632 2872 // 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!"); 2633 2879 } 2634 2880 } … … 2686 2932 } 2687 2933 2688 // construct lp ring with r->N variables, r->names vars....2934 // construct lp, C ring with r->N variables, r->names vars.... 2689 2935 ring rModifyRing_Simple(ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, unsigned long exp_limit, BOOLEAN &simple) 2690 2936 { … … 2868 3114 r->MixedOrder=TRUE; 2869 3115 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 2870 3128 default: 2871 3129 dReportError("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__); … … 2939 3197 int** wvhdl = r->wvhdl; 2940 3198 2941 if (order[0]==ringorder_S ||order[0]==ringorder_s )3199 if (order[0]==ringorder_S ||order[0]==ringorder_s || order[0]==ringorder_IS) 2942 3200 { 2943 3201 order++; … … 2956 3214 ||( 2957 3215 ((order[1]==ringorder_c)||(order[1]==ringorder_C) 2958 ||(order[1]==ringorder_S) 3216 ||(order[1]==ringorder_S) ||(order[1]==ringorder_IS) 2959 3217 ||(order[1]==ringorder_s)) 2960 3218 && (order[0]!=ringorder_M) … … 2963 3221 { 2964 3222 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)|| 2966 3224 (order[1]==ringorder_s))) 2967 3225 r->ComponentOrder=-1; … … 2988 3246 else if (((order[0]==ringorder_c) 2989 3247 ||(order[0]==ringorder_C) 2990 ||(order[0]==ringorder_S) 3248 ||(order[0]==ringorder_S) ||(order[0]==ringorder_IS) 2991 3249 ||(order[0]==ringorder_s)) 2992 3250 && (order[1]!=ringorder_M) 2993 3251 && (order[2]==0)) 2994 3252 { 2995 if ((order[0]==ringorder_C)||(order[0]==ringorder_S)|| 3253 if ((order[0]==ringorder_C)||(order[0]==ringorder_S)|| (order[0]==ringorder_IS) || 2996 3254 order[0]==ringorder_s) 2997 3255 r->ComponentOrder=-1; … … 3017 3275 else 3018 3276 { 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)) 3020 3278 { 3021 3279 rSetFirstWv(r, 1, order, block1, wvhdl); … … 3036 3294 if ((order[0]!=ringorder_c) 3037 3295 && (order[0]!=ringorder_C) 3038 && (order[0]!=ringorder_S) 3296 && (order[0]!=ringorder_S) && (order[0]!=ringorder_IS) 3039 3297 && (order[0]!=ringorder_s)) 3040 3298 { … … 3141 3399 int j=0; 3142 3400 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 3144 3404 for(i=0;i<n;i++) 3145 3405 { … … 3341 3601 3342 3602 case ringorder_S: 3603 assume(typ_i == 0 && j == 0); 3343 3604 rO_Syzcomp(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]); 3344 3605 need_to_add_comp=TRUE; … … 3347 3608 3348 3609 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]); 3350 3612 need_to_add_comp=TRUE; 3351 3613 typ_i++; 3352 3614 break; 3353 3615 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 } 3354 3633 case ringorder_unspec: 3355 3634 case ringorder_no: … … 3441 3720 i=0; // position 3442 3721 j=0; // index in r->typ 3443 if (i==r->pCompIndex) i++; 3722 if (i==r->pCompIndex) i++; // IS??? 3444 3723 while ((j < r->OrdSize) 3445 3724 && ((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) || 3447 3726 (r->order[r->typ[j].order_index] == ringorder_aa))) 3448 3727 { 3449 3728 i++; j++; 3450 3729 } 3730 // No use of j anymore!!!???? 3731 3451 3732 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 3453 3734 3454 3735 // ---------------------------- … … 3483 3764 if (r->VarOffset != NULL) 3484 3765 { 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 3485 3805 if (r->PolyBin != NULL) 3486 3806 omUnGetSpecBin(&(r->PolyBin)); 3487 3807 3488 3808 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 3501 3810 if (r->ordsgn != NULL && r->CmpL_Size != 0) 3502 3811 omFreeSize((ADDRESS)r->ordsgn,r->ExpL_Size*sizeof(long)); … … 3618 3927 // corresponds to ro_typ from ring.h: 3619 3928 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"}; 3621 3930 int i,j; 3622 3931 … … 3640 3949 for(j=0;j<r->OrdSize;j++) 3641 3950 { 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 } 3663 4004 } 3664 4005 PrintLn(); … … 3739 4080 #endif // RDEBUG 3740 4081 4082 /// debug-print monomial poly/vector p, assuming that it lives in the ring R 4083 inline 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. 4097 void 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 3741 4130 3742 4131 /*2 … … 3791 4180 3792 4181 // for the time being, this is still here 3793 static ring rAssure_SyzComp(ring r, BOOLEAN complete = TRUE); 3794 3795 #define MYTEST 0 4182 static ring rAssure_SyzComp(const ring r, BOOLEAN complete = TRUE); 3796 4183 3797 4184 ring rCurrRingAssure_SyzComp() 3798 4185 { 3799 #ifdef HAVE_PLURAL3800 4186 #if MYTEST 3801 4187 PrintS("rCurrRingAssure_SyzComp(), currRing: \n"); … … 3804 4190 rDebugPrint(currRing); 3805 4191 #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 { 3814 4199 rChangeCurrRing(r); 3815 4200 assume(currRing == r); 3816 4201 3817 #ifdef HAVE_PLURAL3818 #if MYTEST3819 PrintS("rCurrRingAssure_SyzComp(): currRing': ");3820 rWrite(currRing);3821 #ifdef RDEBUG3822 rDebugPrint(currRing);3823 #endif3824 #endif3825 #endif3826 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_PLURAL3835 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 #endif3841 }3842 3843 #ifdef HAVE_PLURAL3844 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 #endif3849 3850 }3851 3852 assume(currRing == r);3853 3854 3855 #ifdef HAVE_PLURAL3856 4202 #if MYTEST 3857 4203 PrintS("\nrCurrRingAssure_SyzComp(): new currRing: \n"); … … 3860 4206 rDebugPrint(currRing); 3861 4207 #endif 3862 #endif 3863 #endif 4208 PrintS("\n"); 4209 #endif 4210 } 3864 4211 3865 4212 return r; 3866 4213 } 3867 4214 3868 static ring rAssure_SyzComp(ring r, BOOLEAN complete) 3869 { 3870 if (r->order[0] == ringorder_s) return r; 4215 static 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 } 3871 4223 ring res=rCopy0(r, FALSE, FALSE); 3872 4224 int i=rBlocks(r); … … 3905 4257 assume(rIsPluralRing(r) == rIsPluralRing(res)); 3906 4258 #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 3908 4310 return res; 3909 4311 } … … 3979 4381 if (r->qideal!=NULL) 3980 4382 { 3981 res->qideal=idrCopyR_NoSort(r->qideal,r );4383 res->qideal=idrCopyR_NoSort(r->qideal,r, res); 3982 4384 #ifdef HAVE_PLURAL 3983 4385 if (rIsPluralRing(res)) … … 4120 4522 WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...? 4121 4523 } 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 4128 4534 rTest(new_r); 4129 4535 rTest(old_r); … … 4132 4538 } 4133 4539 4540 // Moves _c or _C ordering to the last place AND adds _s on the 1st place 4134 4541 ring rCurrRingAssure_SyzComp_CompLastBlock() 4135 4542 { 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!!! 4138 4545 4139 4546 if (new_r != currRing) … … 4164 4571 WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...? 4165 4572 } 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 4172 4583 rTest(new_r); 4173 4584 rTest(old_r); … … 4215 4626 4216 4627 4628 ring 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 4217 4762 ring rCurrRingAssure_dp_S() 4218 4763 { … … 4228 4773 { 4229 4774 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! 4781 bool 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; 4230 4863 } 4231 4864 … … 4258 4891 currRing->typ[0].data.syz.limit = k; 4259 4892 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)) // ??? 4262 4903 { 4263 4904 dReportError("syzcomp in incompatible ring"); … … 4613 5254 // should not occur: 4614 5255 case ringorder_S: 5256 case ringorder_IS: 4615 5257 case ringorder_s: 4616 5258 case ringorder_aa: … … 4691 5333 if (src->qideal != NULL) 4692 5334 { 4693 id Delete(&(r->qideal));5335 id_Delete(&(r->qideal), r); 4694 5336 4695 5337 #ifdef HAVE_PLURAL -
kernel/ring.h
r45c67dc r645a19 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1.4 1 2009-05-06 12:53:49 SingularExp $ */9 /* $Id: ring.h,v 1.42 2009-07-20 12:00:51 motsak Exp $ */ 10 10 11 11 /* includes */ … … 28 28 void rKill(ring r); 29 29 ring rCopy(ring r); 30 ring rCopy0(ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE);30 ring rCopy0(const ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE); 31 31 void rNameCheck(ring R); 32 32 ring rOpposite(ring r); 33 33 ring rEnvelope(ring r); 34 34 35 // we must always have this test!35 /// we must always have this test! 36 36 inline bool rIsPluralRing(const ring r) 37 37 { … … 248 248 n_coeffType rFieldType(ring r); 249 249 250 // this needs to be called whenever a new ring is created: new fields251 // in ring are created (like VarOffset), unless they already exist252 // with force == 1, new fields are _always_ created (overwritten),253 // even if they exist250 /// 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 254 254 BOOLEAN rComplete(ring r, int force = 0); 255 // use this to free fields created by rComplete 255 // use this to free fields created by rComplete //? 256 256 257 257 inline int rBlocks(ring r) … … 276 276 } 277 277 278 // order stuff278 /// order stuff 279 279 typedef enum rRingOrder_t 280 280 { 281 281 ringorder_no = 0, 282 282 ringorder_a, 283 ringorder_a64, // for int64 weights283 ringorder_a64, ///< for int64 weights 284 284 ringorder_c, 285 285 ringorder_C, 286 286 ringorder_M, 287 ringorder_S, 288 ringorder_s, 287 ringorder_S, ///< S? 288 ringorder_s, ///< s? 289 289 ringorder_lp, 290 290 ringorder_dp, … … 300 300 ringorder_L, 301 301 // 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 304 305 ringorder_unspec 305 306 } rRingOrder_t; … … 307 308 typedef enum rOrderType_t 308 309 { 309 rOrderType_General = 0, // non-simple ordering as specified by currRing310 rOrderType_CompExp, // simple ordering, component has priority311 rOrderType_ExpComp, // simple ordering, exponent vector has priority312 // component not compatible with exp-vector order313 rOrderType_Exp, // simple ordering, exponent vector has priority314 // component is compatible with exp-vector order315 rOrderType_Syz, // syzygy ordering316 rOrderType_Schreyer, // Schreyer ordering317 rOrderType_Syz2dpc, // syzcomp2dpc318 rOrderType_ExpNoComp // simple ordering, differences in component are319 // not considered310 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 320 321 } rOrderType_t; 321 322 322 inline BOOLEAN rIsSyzIndexRing( ring r)323 inline BOOLEAN rIsSyzIndexRing(const ring r) 323 324 { return r->order[0] == ringorder_s;} 324 325 325 inline int rGetCurrSyzLimit(ring r = currRing) 326 { return (r->order[0] == ringorder_s ? 327 r->typ[0].data.syz.limit : 0);} 326 inline int rGetCurrSyzLimit(const ring r = currRing) 327 { return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);} 328 328 329 329 // Ring Manipulations … … 334 334 ring rCurrRingAssure_dp_C(); 335 335 ring rCurrRingAssure_C_dp(); 336 // makes sure that c/C ordering is last ordering 336 337 /// makes sure that c/C ordering is last ordering 337 338 ring 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 339 341 ring rCurrRingAssure_SyzComp_CompLastBlock(); 340 342 ring rAssure_TDeg(ring r, int start_var, int end_var, int &pos); 341 343 342 // return the max-comonent wchich has syzIndex i343 // Assume: i<= syzIndex_limit344 /// return the max-comonent wchich has syzIndex i 345 /// Assume: i<= syzIndex_limit 344 346 int rGetMaxSyzComp(int i); 345 347 346 348 BOOLEAN rHasSimpleOrder(const ring r); 347 // returns TRUE, if simple lp or ls ordering 349 350 /// returns TRUE, if simple lp or ls ordering 348 351 BOOLEAN rHasSimpleLexOrder(const ring r); 352 349 353 // return TRUE if p->exp[r->pOrdIndex] holds total degree of p */ 350 354 //inline BOOLEAN rHasGlobalOrdering(const ring r=currRing) … … 357 361 #define rHasLocalOrMixedOrdering_currRing() (pOrdSgn==-1) 358 362 BOOLEAN 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 360 365 BOOLEAN rOrd_SetCompRequiresSetm(ring r); 361 366 rOrderType_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 363 369 BOOLEAN rIsPolyVar(int i, ring r = currRing); 364 370 … … 380 386 BOOLEAN omit_comp, 381 387 unsigned long exp_limit); 382 // construct Wp, C ring 388 389 /// construct Wp, C ring 383 390 ring rModifyRing_Wp(ring r, int* weights); 384 391 void rModify_a_to_A(ring r); … … 391 398 void rKillModifiedRing_Simple(ring r); 392 399 400 #ifdef RDEBUG 393 401 void rDebugPrint(ring r); 394 402 void pDebugPrint(poly p); 395 403 void 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. 408 void p_DebugPrint(const poly p, const ring lmRing, const ring tailRing, const int nTerms = 2); 396 409 397 410 int64 * rGetWeightVec(ring r); -
kernel/structs.h
r45c67dc r645a19 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1.6 1 2009-05-29 16:21:04 SingularExp $ */6 /* $Id: structs.h,v 1.62 2009-07-20 12:00:51 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 356 356 // with possibly negative weights 357 357 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) 360 361 ro_none 361 362 } … … 422 423 423 424 typedef 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 432 struct 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 442 struct 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 454 typedef struct sro_IS sro_IS; 455 typedef struct sro_ISTemp sro_ISTemp; 424 456 425 457 #ifndef OM_ALLOC_H … … 439 471 sro_syzcomp syzcomp; 440 472 sro_syz syz; 473 sro_IS is; 474 sro_ISTemp isTemp; 441 475 } data; 442 476 }; … … 631 665 BOOLEAN ShortOut; 632 666 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; // ??? 638 671 639 672
Note: See TracChangeset
for help on using the changeset viewer.