Changeset 542685e in git


Ignore:
Timestamp:
Oct 20, 2014, 2:55:51 PM (9 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
Children:
06f38e104526d5f14601428e461a6877c1d43d66
Parents:
1965800c56ab5ae85bbaa4c89cbae5719bd81515
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-10-20 14:55:51+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-10-22 13:55:04+02:00
Message:
Updating + Fixing
Location:
Singular
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/schreyer.lib

    r196580 r542685e  
    21882188      exportto(Schreyer, Syzextra::ComputeSyzygy);
    21892189
    2190       exportto(Schreyer, Syzextra::ComputeResolution);     
     2190      exportto(Schreyer, Syzextra::ComputeResolution);
     2191
     2192//      newstruct("SRESOLUTION","ring _r, resolution _res"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218
     2193//      newstruct("SSYZYGY","ring _r, module _syz"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218
     2194      // TODO: SSres - return SRESOLUTION?
     2195
     2196//      system("install","SRESOLUTION","string",SRESOLUTION_string, 1);
     2197//      system("install","SRESOLUTION","print",SRESOLUTION_print, 1);
     2198//      system("install","SRESOLUTION","list",SRESOLUTION_list, 1);
     2199
     2200//      system("install","SRESOLUTION","betti",SRESOLUTION_betti, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299
     2201//      system("install","SRESOLUTION","minres",SRESOLUTION_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383
     2202
     2203      // TODO: SSsyz? SSYZYGY? // TODO: C/C++ computation for Syzygy?
     2204//      system("install","SSYZYGY","string",SSYZYGY_string, 1);
     2205//      system("install","SSYZYGY","print",SSYZYGY_print, 1);
     2206//      system("install","SSYZYGY","module",SSYZYGY_module, 1);
    21912207    }
    21922208
  • Singular/dyn_modules/syzextra/syzextra.cc

    r196580 r542685e  
    526526    for(TReducers::const_iterator vit = v.begin(); (vit != v.end()) && coprime; ++vit )
    527527    {
    528       assume( m_L->m[(*vit)->m_label] == (*vit)->m_lt );
    529 
    530       const poly p = (*vit)->m_lt;
     528      assume( (*vit)->CheckLT( m_L ) );
     529
     530      const poly p = (*vit)->lt();
    531531
    532532      assume( p_GetComp(p, r) == comp );
     
    551551        poly ss = p_LmInit(t, r);
    552552        p_SetCoeff0(ss, n_Init(1, r), r); // for delete & printout only!...
    553         p_SetComp(ss, (*vit)->m_label + 1, r); // coeff?
     553        p_SetComp(ss, (*vit)->label() + 1, r); // coeff?
    554554        p_Setm(ss, r);
    555555
     
    567567      }
    568568
     569      assume( p == (*vit)->lt() );
     570      assume( (*vit)->CheckLT( m_L ) );
    569571    }
    570572
     
    925927poly SchreyerSyzygyComputation::TraverseNF(const poly a, const poly a2) const
    926928{
     929#ifndef SING_NDEBUG
     930  if( __DEBUG__ )
     931  {
     932    m_div.Verify();
     933    m_checker.Verify();
     934  }
     935#endif
     936
    927937  const ideal& L = m_idLeads;
    928938  const ideal& T = m_idTails;
     
    937947  assume( a != NULL );
    938948
     949#ifndef SING_NDEBUG
     950  if( __DEBUG__ )
     951  {
     952    PrintS("SchreyerSyzygyComputation::TraverseNF(syz_lead, poly syz_2), \n");
     953    PrintS("syz_lead: \n");
     954    dPrint(a, R, R, 1);
     955    PrintS("syz_2: \n");
     956    dPrint(a2, R, R, 1);
     957    PrintLn();
     958  }
     959#endif
     960 
    939961  if( __TREEOUTPUT__ )
    940962  {
     
    947969  poly t = TraverseTail(aa, r);
    948970
     971#ifndef SING_NDEBUG
     972  if( __DEBUG__ )
     973  {
     974    m_div.Verify();
     975    m_checker.Verify();
     976  }
     977#endif
     978 
    949979  if( a2 != NULL )
    950980  {
     
    968998       PrintS("]},");
    969999
     1000#ifndef SING_NDEBUG
     1001    if( __DEBUG__ )
     1002    {
     1003      m_div.Verify();
     1004      m_checker.Verify();
     1005    }
     1006#endif
    9701007  } else
    9711008    t = p_Add_q(t, ReduceTerm(aa, L->m[r], a), R);
     
    9771014  if( __TREEOUTPUT__ )
    9781015  {
    979      PrintS("], \"noderesult\": \""); writeLatexTerm(t, R, true, false); PrintS("\" },");
    980   }
     1016    poly tt = pp_Add_qq( a, t, R);  // TODO: ADD a?
     1017    PrintS("], \"noderesult\": \""); writeLatexTerm(tt, R, true, false); PrintS("\", \"proc\": \"TraverseNF\" },");
     1018    p_Delete(&tt, R);
     1019  }
     1020#ifndef SING_NDEBUG
     1021  if( __DEBUG__ )
     1022  {
     1023    PrintS("SchreyerSyzygyComputation::TraverseNF(syz_lead, poly syz_2), ==>>> \n");
     1024    dPrint(t, R, R, 0);
     1025    PrintLn();
     1026  }
     1027#endif
     1028
     1029#ifndef SING_NDEBUG
     1030  if( __DEBUG__ )
     1031  {
     1032    m_div.Verify();
     1033    m_checker.Verify();
     1034  }
     1035#endif
     1036 
    9811037  return t;
    9821038}
    9831039
    984 
    9851040void SchreyerSyzygyComputation::ComputeSyzygy()
    9861041{
     1042#ifndef SING_NDEBUG
     1043  if( __DEBUG__ )
     1044  {
     1045    m_div.Verify();
     1046    m_checker.Verify();
     1047  }
     1048#endif
     1049
    9871050  assume( m_idLeads != NULL );
    9881051  assume( m_idTails != NULL );
     
    10841147#endif
    10851148
    1086   for( int k = size - 1; k >= 0; k-- )
     1149#ifndef SING_NDEBUG
     1150  if( __DEBUG__ )
     1151  {
     1152    m_div.Verify();
     1153    m_checker.Verify();
     1154  }
     1155#endif
     1156 
     1157//  for( int k = 0; k < size; ++k ) // TODO: reversed order =>> ALL wrong :((((
     1158  for( int k = size - 1; k >= 0; --k )
    10871159  {
    10881160    const poly a = LL->m[k]; assume( a != NULL );
     
    11081180    //    TT->m[k] = a2;
    11091181
     1182#ifndef SING_NDEBUG
     1183    if( __DEBUG__ )
     1184    {
     1185      m_div.Verify();
     1186      m_checker.Verify();
     1187    }
     1188#endif
     1189
     1190    poly nf;
     1191   
    11101192    if( method )
    1111       TT->m[k] = SchreyerSyzygyNF(a, a2);
     1193      nf = SchreyerSyzygyNF(a, a2);
    11121194    else
    1113       TT->m[k] = TraverseNF(a, a2); // TODO: WRONG
     1195      nf = TraverseNF(a, a2); // TODO: WRONG
     1196
     1197#ifndef SING_NDEBUG
     1198    if( __DEBUG__ )
     1199    {
     1200      m_div.Verify();
     1201      m_checker.Verify();
     1202    }
     1203#endif
     1204
     1205    TT->m[k] = nf; // ???
     1206   
     1207#ifndef SING_NDEBUG
     1208    if( __DEBUG__ )
     1209    {
     1210      m_div.Verify();
     1211      m_checker.Verify();
     1212    }
     1213#endif
    11141214
    11151215    if( __SYZCHECK__ )     
    11161216    {
     1217#ifndef SING_NDEBUG
     1218      if( __DEBUG__ )
     1219      {
     1220      m_div.Verify();
     1221        m_checker.Verify();
     1222      }
     1223#endif
    11171224      // TODO: check the correctness (syzygy property): a + TT->m[k] should be a syzygy!!!
    11181225
     
    11211228      poly vp = p_VectorProductLT(s, L, T, R);
    11221229
    1123       if( (__DEBUG__ | __TREEOUTPUT__) && (vp != NULL) )
     1230      if( __DEBUG__ && (vp != NULL) && ! __TREEOUTPUT__ )
    11241231      {
    11251232        Warn("SchreyerSyzygyComputation::ComputeSyzygy: failed syzygy property for syzygy [%d], non-zero image is as follows: ", k);       
     
    11371244          s = TraverseNF(a, a2);
    11381245
    1139         s = p_Add_q( a, s, R); // another syzygy
     1246        s = p_Add_q( p_Copy(a, R), s, R); // another syzygy // :((((
    11401247        PrintS("SchreyerSyzygyComputation::ComputeSyzygy: The other method gives the following  syzygy: ");
    11411248        dPrint(s, R, R, 0);
     
    11511258          dPrint(vp, R, R, 0);
    11521259        }
     1260
     1261#ifndef SING_NDEBUG
     1262        if( __DEBUG__ )
     1263        {
     1264          m_div.Verify();
     1265          m_checker.Verify();
     1266        }
     1267#endif
    11531268       
    11541269      } else
     
    11581273    }
    11591274
     1275#ifndef SING_NDEBUG
     1276    if( __DEBUG__ )
     1277    {
     1278      m_div.Verify();
     1279      m_checker.Verify();
     1280    }
     1281#endif
    11601282  }
    11611283
     
    12201342}
    12211343
    1222 #define NOPRODUCT 1
     1344#define NOPRODUCT 0
    12231345
    12241346poly SchreyerSyzygyComputation::SchreyerSyzygyNF(const poly syz_lead, poly syz_2) const
    12251347{
    1226 
    12271348  assume( !__IGNORETAILS__ );
    12281349
     
    12331354  assume( syz_lead != NULL );
    12341355
     1356
     1357#ifndef SING_NDEBUG
     1358  if( __DEBUG__ )
     1359  {
     1360    PrintS("SchreyerSyzygyComputation::SchreyerSyzygyNF(syz_lead, poly syz_2), \n");
     1361    PrintS("syz_lead: \n");
     1362    dPrint(syz_lead, r, r, 1);
     1363    PrintS("syz_2: \n");
     1364    dPrint(syz_2, r, r, 1);
     1365    PrintLn();
     1366  }
     1367#endif
     1368
    12351369  if( __TREEOUTPUT__ )
    12361370  {
    1237 //     PrintS("%%%% BEGIN LIFTHYBRID DIAGRAMM\n");
    1238     PrintS("{   \"nodelabel\": \""); writeLatexTerm(syz_lead, r); PrintS("\", \"children\": [");
     1371    PrintS("{   \"nodelabel\": \""); writeLatexTerm(syz_lead, r);
     1372    PrintS("\", \"children\": [");
    12391373  }
    12401374
     
    12591393    if( __TREEOUTPUT__ )
    12601394    {
    1261       PrintS("{ \"nodelabel\": \""); writeLatexTerm(syz_2, r); PrintS("\", \"edgelable\": \""); writeLatexTerm(aa, r, false); PrintS("\" },");
     1395      PrintS("{ \"nodelabel\": \""); writeLatexTerm(syz_2, r); PrintS("\", \"edgelabel\": \""); writeLatexTerm(aa, r, false); PrintS("\" },");
    12621396    }
    12631397
     
    13291463      if( __TREEOUTPUT__ )
    13301464      {
    1331         PrintS("{ \"nodelabel\": \""); writeLatexTerm(t, r); PrintS("\", \"edgelable\": \""); writeLatexTerm(spoly, r, false); PrintS("\" },");
     1465        PrintS("{ \"nodelabel\": \""); writeLatexTerm(t, r); PrintS("\", \"edgelabel\": \""); writeLatexTerm(spoly, r, false); PrintS("\" },");
    13321466      }
    13331467
     
    13551489  }
    13561490
     1491#ifndef SING_NDEBUG
     1492  if( __DEBUG__ )
     1493  {
     1494    PrintS("SchreyerSyzygyComputation::SchreyerSyzygyNF(syz_lead, poly syz_2) =>>> \n");
     1495    dPrint(result, r, r, 0);
     1496    PrintLn();
     1497    // TODO: Add SyzCheck!!!???
     1498  }
     1499#endif
    13571500
    13581501  return result;
     
    13691512poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, const int tail) const
    13701513{
     1514#ifndef SING_NDEBUG
     1515  if( __DEBUG__ )
     1516  {
     1517    m_div.Verify();
     1518    m_checker.Verify();
     1519  }
     1520#endif
     1521
    13711522  const ring& r = m_rBaseRing;
    13721523
     
    13991550       {
    14001551//         PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false);
    1401 //         Print(" \\\\cdot \\\\GEN{%d}\", \"children\": [ ", tail + 1);
    1402           Print("{ \"lookedupnode\": \"1\", \"nodelabel\": \"");
    1403           writeLatexTerm(p, r, true, false);
     1552//         Print("  \\\\GEN{%d}\", \"children\": [ ", tail + 1);
     1553         PrintS("{ \"proc\": \"TraverseTail-lookup\", \"nodelabel\": \"");
     1554         writeLatexTerm(multiplier, r, false); Print(" \\\\GEN{%d}\", \"look-up-poly\": \"", tail + 1);
     1555         writeLatexTerm(p, r, true, false);
     1556         PrintS("\", ");
    14041557       }
    14051558
     
    14111564
    14121565         if( __TREEOUTPUT__ )
    1413            Print("\", \"RESCALEDRESULT\": \"1\" },");
     1566           PrintS("\"rescale\": \"1\", ");
    14141567       } else
    14151568       {
    14161569         if( __TREEOUTPUT__ )
    1417            Print("\", \"RESCALEDRESULT\": \"0\" },");
     1570           PrintS("\"rescale\": \"0\", ");
    14181571       }
    14191572
     1573       if( __TREEOUTPUT__ )
     1574       {
     1575         PrintS("\"noderesult\": \"");
     1576         writeLatexTerm(p, r, true, false);
     1577         PrintS("\" },");
     1578       }
     1579
     1580#ifndef SING_NDEBUG
     1581       if( __DEBUG__ )
     1582       {
     1583         m_div.Verify();
     1584         m_checker.Verify();
     1585       }
     1586#endif
     1587       
    14201588       return p;
    14211589     }
    14221590
     1591
    14231592     if( __TREEOUTPUT__ )
    14241593     {
    1425 //        PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); Print(" \\\\cdot \\\\GEN{%d}\", \"children\": [", tail + 1);
     1594       PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); Print(" \\\\GEN{%d}\", \"children\": [", tail + 1);
    14261595     }
    1427 
     1596     
    14281597     const poly p = ComputeImage(multiplier, tail);
     1598
    14291599     T.insert( TP2PCache::value_type(p_Copy(multiplier, r), p) ); //     T[ multiplier ] = p;
    14301600
     
    14341604     if( __TREEOUTPUT__ )
    14351605     {
    1436 //        PrintS("], \"storedResult\": \""); writeLatexTerm(p, r, true, false); PrintS("\" },");
     1606       PrintS("], \"noderesult\": \""); writeLatexTerm(p, r, true, false); PrintS("\", \"proc\": \"TraverseTail-compute-and-store1\" },");
    14371607     }
    14381608
     1609#ifndef SING_NDEBUG
     1610     if( __DEBUG__ )
     1611     {
     1612       m_div.Verify();
     1613       m_checker.Verify();
     1614     }
     1615#endif
     1616     
    14391617     return p_Copy(p, r);
    14401618  }
     
    14441622  if( __TREEOUTPUT__ )
    14451623  {
    1446 //     PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); Print(" \\\\cdot \\\\GEN{%d}\", \"children\": [", tail + 1);
     1624    PrintS("{ \"nodelabel\": \""); writeLatexTerm(multiplier, r, false); Print(" \\\\GEN{%d}\", \"children\": [", tail + 1);
    14471625  }
    14481626
     
    14591637  if( __TREEOUTPUT__ )
    14601638  {
    1461 //     PrintS("], \"storedResult\": \""); writeLatexTerm(p, r, true, false); PrintS("\" },");
    1462   }
     1639    PrintS("], \"noderesult\": \""); writeLatexTerm(p, r, true, false); PrintS("\", \"proc\": \"TraverseTail-compute-and-store2\" },");
     1640  }
     1641
     1642#ifndef SING_NDEBUG
     1643  if( __DEBUG__ )
     1644  {
     1645    m_div.Verify();
     1646    m_checker.Verify();
     1647  }
     1648#endif
    14631649
    14641650  return p_Copy(p, r);
     
    14781664poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail) const
    14791665{
     1666#ifndef SING_NDEBUG
     1667  if( __DEBUG__ )
     1668  {
     1669    m_div.Verify();
     1670    m_checker.Verify();
     1671  }
     1672#endif
     1673
    14801674  assume( !__IGNORETAILS__ );
    14811675
     
    15181712    sBucketClearAdd(sum, &s, &len);
    15191713    assume( pLength(s) == len );
     1714#ifndef SING_NDEBUG
     1715    if( __DEBUG__ )
     1716    {
     1717      m_div.Verify();
     1718      m_checker.Verify();
     1719    }
     1720#endif
     1721
    15201722    return s;
    15211723  }
    15221724
     1725#ifndef SING_NDEBUG
     1726  if( __DEBUG__ )
     1727  {
     1728    m_div.Verify();
     1729    m_checker.Verify();
     1730  }
     1731#endif
     1732
    15231733  return NULL;
    15241734
     
    15301740poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const
    15311741{
     1742#ifndef SING_NDEBUG
     1743  if( __DEBUG__ )
     1744  {
     1745    m_div.Verify();
     1746    m_checker.Verify();
     1747  }
     1748#endif
     1749
    15321750  assume( !__IGNORETAILS__ );
    15331751
     
    15501768#if NOPRODUCT
    15511769    s = m_div.FindReducer(multiplier, term4reduction, syztermCheck, m_checker);
    1552 
     1770   
    15531771    if( s == NULL ) // No Reducer?
    15541772     return s;
     
    15561774    if( __TREEOUTPUT__ )
    15571775    {
    1558       PrintS("{ \"nodelabel\": \""); writeLatexTerm(s, r);
     1776      poly product = pp_Mult_mm(multiplier, term4reduction, r);
     1777      PrintS("{ \"proc\": \"ReduceTerm-NOPRODUCT\", \"nodelabel\": \""); writeLatexTerm(s, r); PrintS("\", \"edgelabel\": \""); writeLatexTerm(product, r, false);
     1778      p_Delete(&product, r);
    15591779    }
    15601780
     
    15621782    // NOTE: only LT(term4reduction) should be used in the following:
    15631783    poly product = pp_Mult_mm(multiplier, term4reduction, r);
    1564     s = m_div.FindReducer(product, syztermCheck, m_checker);
     1784    s = m_div.FindReducer(product, syztermCheck, m_checker); // ??
    15651785
    15661786    if( s == NULL ) // No Reducer?
     
    15691789    if( __TREEOUTPUT__ )
    15701790    {
    1571       PrintS("{ \"nodelabel\": \""); writeLatexTerm(s, r); PrintS("\", \"edgelable\": \""); writeLatexTerm(product, r, false);
     1791      PrintS("{ \"proc\": \"ReduceTerm-PRODUCT\", \"nodelabel\": \""); writeLatexTerm(s, r); PrintS("\", \"edgelabel\": \""); writeLatexTerm(product, r, false);
    15721792    }
    15731793
     
    15761796  }
    15771797
     1798#ifndef SING_NDEBUG
     1799  if( __DEBUG__ )
     1800  {
     1801    m_div.Verify();
     1802    m_checker.Verify();
     1803  }
     1804#endif
     1805
     1806#ifndef SING_NDEBUG
     1807  if( __DEBUG__ )
     1808  {
     1809    m_div.Verify();
     1810    m_checker.Verify();
     1811  }
     1812#endif
     1813 
    15781814  if( s == NULL ) // No Reducer?
    15791815    return s;
     
    16021838  }
    16031839
     1840#ifndef SING_NDEBUG
     1841  if( __DEBUG__ )
     1842  {
     1843    m_div.Verify();
     1844    m_checker.Verify();
     1845  }
     1846#endif
     1847
     1848 
    16041849  return s;
    16051850}
     
    16411886CLeadingTerm::CLeadingTerm(unsigned int _label,  const poly _lt, const ring R):
    16421887    m_sev( p_GetShortExpVector(_lt, R) ),  m_label( _label ),  m_lt( _lt )
    1643 { }
     1888#ifndef SING_NDEBUG
     1889    , _R(R), m_lt_copy( p_Copy(_lt, R) )
     1890#endif 
     1891   
     1892{
     1893  assume( pNext(_lt) == NULL );
     1894  assume( sev() == p_GetShortExpVector(lt(), R) );
     1895}
     1896
     1897CLeadingTerm::~CLeadingTerm()
     1898{
     1899#ifndef SING_NDEBUG
     1900  assume( p_EqualPolys(m_lt, m_lt_copy, _R) );
     1901  assume( m_sev == p_GetShortExpVector(m_lt, _R) );
     1902 
     1903  poly p = const_cast<poly>(m_lt_copy);
     1904  p_Delete(&p, _R);
     1905#endif 
     1906}
     1907
     1908poly CLeadingTerm::lt() const
     1909{
     1910#ifndef SING_NDEBUG
     1911//  assume( (long)(*m_lt) == (long)(*m_lt_copy) );
     1912  assume( p_EqualPolys(m_lt, m_lt_copy, _R) );
     1913  assume( m_sev == p_GetShortExpVector(m_lt, _R) ); 
     1914#endif
     1915  return m_lt;
     1916}
     1917unsigned long CLeadingTerm::sev() const
     1918{
     1919#ifndef SING_NDEBUG
     1920  assume( p_EqualPolys(m_lt, m_lt_copy, _R) );
     1921  assume( m_sev == p_GetShortExpVector(m_lt, _R) ); 
     1922#endif
     1923  return m_sev;
     1924}
     1925
     1926unsigned int CLeadingTerm::label() const
     1927{
     1928#ifndef SING_NDEBUG
     1929  assume( p_EqualPolys(m_lt, m_lt_copy, _R) );
     1930  assume( m_sev == p_GetShortExpVector(m_lt, _R) ); 
     1931#endif
     1932  return m_label;
     1933}
     1934
    16441935
    16451936
     
    17352026}
    17362027
     2028
     2029bool CLeadingTerm::CheckLT( const ideal & L ) const
     2030{
     2031//  for( int i = IDELEMS(L); i >= 0; --i) assume( pNext(L->m[i]) == NULL ); // ???
     2032  return ( L->m[label()] == lt() );
     2033}
     2034
    17372035bool CLeadingTerm::DivisibilityCheck(const poly product, const unsigned long not_sev, const ring r) const
    17382036{
    1739   const poly p = m_lt;
    1740 
    1741   assume( p_GetComp(p, r) == p_GetComp(product, r) );
    1742 
    1743 //  const int k = m_label;
     2037  // may have no coeff yet
     2038//  assume ( !n_IsZero( p_GetCoeff(product, r), r ) );
     2039
     2040  assume ( !n_IsZero( p_GetCoeff(lt(), r), r ) );
     2041  assume( sev() == p_GetShortExpVector(lt(), r) );
     2042
     2043  assume( product != NULL );
     2044  assume( (p_GetComp(lt(), r) == p_GetComp(product, r)) || (p_GetComp(lt(), r) == 0) );
     2045
     2046#ifndef SING_NDEBUG
     2047  assume( r == _R );
     2048#endif   
     2049 
     2050//  const int k = label();
    17442051//  assume( m_L->m[k] == p );
    17452052
    1746   const unsigned long p_sev = m_sev;
    1747 
    1748   assume( p_sev == p_GetShortExpVector(p, r) );
    1749 
    1750   return p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r);
     2053  return p_LmShortDivisibleByNoComp(lt(), sev(), product, not_sev, r);
    17512054
    17522055}
     
    17562059bool CLeadingTerm::DivisibilityCheck(const poly m, const poly t, const unsigned long not_sev, const ring r) const
    17572060{
    1758   const poly p = m_lt;
    1759 
    1760   assume( p_GetComp(p, r) == p_GetComp(t, r) );
     2061  assume ( !n_IsZero( p_GetCoeff(lt(), r), r ) );
     2062  assume( sev() == p_GetShortExpVector(lt(), r) );
     2063
     2064  assume( m != NULL );
     2065  assume( t != NULL ); 
     2066  assume ( !n_IsZero( p_GetCoeff(m, r), r ) );
     2067  assume ( !n_IsZero( p_GetCoeff(t, r), r ) );
     2068
    17612069// assume( p_GetComp(m, r) == 0 );
    1762 
    1763 //  const int k = m_label;
     2070  assume( (p_GetComp(lt(), r) == p_GetComp(t, r))  || (p_GetComp(lt(), r) == 0)  );
     2071
     2072//  const int k = label();
    17642073//  assume( m_L->m[k] == p );
    17652074
    1766   const unsigned long p_sev = m_sev;
    1767   assume( p_sev == p_GetShortExpVector(p, r) );
    1768 
    1769   if (p_sev & not_sev)
     2075#ifndef SING_NDEBUG
     2076  assume( r == _R );
     2077#endif   
     2078 
     2079  if (sev() & not_sev)
    17702080    return false;
    17712081
    1772   return _p_LmDivisibleByNoComp(p, m, t, r);
    1773 
     2082  return _p_LmDivisibleByNoComp(lt(), m, t, r);
    17742083//  return p_LmShortDivisibleByNoComp(p, p_sev, product, not_sev, r);
    1775 
    17762084}
    17772085
     
    18032111    {
    18042112      assume( m_comp >= 0 );
    1805       assume( m_reds.m_L != NULL );
     2113      assume( m_reds.m_L != NULL ); /// TODO: m_L should stay the same!!!
     2114     
     2115      assume( product != NULL ); // may have no coeff yet :(
     2116//      assume ( !n_IsZero( p_GetCoeff(product, m_rBaseRing), m_rBaseRing ) );
     2117#ifndef SING_NDEBUG
     2118      if( __DEBUG__ )
     2119        m_reds.Verify();
     2120#endif
    18062121    }
    18072122
     
    18472162      for( ; m_current != m_finish; ++m_current )
    18482163      {
    1849         assume( m_reds.m_L->m[Current().m_label] == Current().m_lt );
     2164        assume( Current().CheckLT( m_reds.m_L ) );
    18502165
    18512166        if( Current().DivisibilityCheck(m_product, m_not_sev, m_rBaseRing) )
     
    18542169          if( __DEBUG__ )
    18552170          {
    1856             Print("CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().m_label);
    1857             dPrint(Current().m_lt, m_rBaseRing, m_rBaseRing, 1);
     2171            Print("CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().label());
     2172            dPrint(Current().lt(), m_rBaseRing, m_rBaseRing, 1);
    18582173          }
    18592174#endif
    18602175//          m_active = true;
     2176          assume( Current().CheckLT( m_reds.m_L ) );
    18612177          return true;
    18622178        }
     2179        assume( Current().CheckLT( m_reds.m_L ) );       
    18632180      }
    18642181
     
    18752192bool CReducerFinder::IsDivisible(const poly product) const
    18762193{
     2194#ifndef SING_NDEBUG
     2195  if( __DEBUG__ )
     2196    DebugPrint();
     2197#endif
     2198 
     2199  assume( product != NULL );
     2200
     2201  // NOTE: q may have no coeff!!! 
     2202
    18772203  CDivisorEnumerator itr(*this, product);
    18782204  if( !itr.Reset() )
     
    19012227  for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
    19022228  {
    1903     assume( m_L->m[(*vit)->m_label] == (*vit)->m_lt );
     2229    assume( (*vit)->CheckLT( m_L ) );
    19042230
    19052231    if( (*vit)->DivisibilityCheck(product, not_sev, r) )
     
    19072233      if( __DEBUG__ )
    19082234      {
    1909         Print("_FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + (*vit)->m_label);
    1910         dPrint((*vit)->m_lt, r, r, 1);
     2235        Print("_FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + (*vit)->label());
     2236        dPrint((*vit)->lt(), r, r, 1);
    19112237      }
    19122238
     
    19212247
    19222248#ifndef SING_NDEBUG
     2249void CReducerFinder::Verify() const
     2250{
     2251  const ring& r = m_rBaseRing;
     2252
     2253  for( CReducersHash::const_iterator it = m_hash.begin(); it != m_hash.end(); it++)
     2254  {
     2255    const TReducers& reducers = it->second;
     2256
     2257    for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
     2258    {
     2259      assume( (*vit)->CheckLT( m_L ) );
     2260     
     2261      const poly p = (*vit)->lt();
     2262     
     2263      const unsigned long p_sev = (*vit)->sev();
     2264      assume( p_sev == p_GetShortExpVector(p, r) );
     2265     
     2266      assume( p_GetComp(p, r) == it->first );
     2267
     2268      const int k = (*vit)->label();       
     2269      assume( m_L->m[k] == p );
     2270       
     2271      pp_Test(p, r, r);
     2272    }
     2273  }
     2274}
     2275   
     2276   
     2277
    19232278void CReducerFinder::DebugPrint() const
    19242279{
     
    19322287    for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
    19332288    {
    1934       const poly p = (*vit)->m_lt;
    1935 
     2289      assume( (*vit)->CheckLT( m_L ) );
     2290     
     2291      const int k = (*vit)->label();
     2292      const poly p = (*vit)->lt();
     2293       
     2294      pp_Test(p, r, r);
     2295     
     2296      assume( m_L->m[k] == p );
     2297
     2298      const unsigned long p_sev = (*vit)->sev();
     2299      assume( p_sev == p_GetShortExpVector(p, r) );
     2300     
    19362301      assume( p_GetComp(p, r) == it->first );
    19372302
    1938       const int k = (*vit)->m_label;
    1939 
     2303      Print("L[%d]: ", k); dPrint(p, r, r, 0); Print("SEV: %ld\n", p_sev);
     2304     
    19402305      assume( m_L->m[k] == p );
    1941 
    1942       const unsigned long p_sev = (*vit)->m_sev;
    1943 
    1944       assume( p_sev == p_GetShortExpVector(p, r) );
    1945 
    1946       Print("L[%d]: ", k); dPrint(p, r, r, 0); Print("SEV: %ld\n", p_sev);
    19472306    }
    19482307  }
     
    19782337      assume( m_multiplier != NULL );
    19792338      assume( m_term != NULL );
     2339     
     2340      assume( m != NULL );
     2341      assume( t != NULL ); 
     2342      assume ( !n_IsZero( p_GetCoeff(m, m_rBaseRing), m_rBaseRing ) );
     2343      assume ( !n_IsZero( p_GetCoeff(t, m_rBaseRing), m_rBaseRing ) );
     2344     
    19802345//      assume( p_GetComp(m_multiplier, m_rBaseRing) == 0 );
     2346#ifndef SING_NDEBUG
     2347      if( __DEBUG__ )
     2348        m_reds.Verify();
     2349#endif
    19812350    }
    19822351
     
    20222391      for( ; m_current != m_finish; ++m_current )
    20232392      {
    2024         assume( m_reds.m_L->m[Current().m_label] == Current().m_lt );
     2393        assume( Current().CheckLT( m_reds.m_L ) );
    20252394
    20262395        if( Current().DivisibilityCheck(m_multiplier, m_term, m_not_sev, m_rBaseRing) )
     
    20292398          if( __DEBUG__ )
    20302399          {
    2031             Print("CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().m_label);
    2032             dPrint(Current().m_lt, m_rBaseRing, m_rBaseRing, 1);
     2400            Print("CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().label());
     2401            dPrint(Current().lt(), m_rBaseRing, m_rBaseRing, 1);
    20332402          }
    20342403#endif
    20352404//          m_active = true;
     2405          assume( Current().CheckLT( m_reds.m_L ) );       
    20362406          return true;
    20372407
    20382408        }
     2409        assume( Current().CheckLT( m_reds.m_L ) );       
    20392410      }
    20402411
     
    20512422                                 const CReducerFinder& syz_checker) const
    20522423{
     2424#ifndef SING_NDEBUG
     2425  if( __DEBUG__ )
     2426  {
     2427    DebugPrint();
     2428    syz_checker.Verify();
     2429  }
     2430#endif
     2431
    20532432  CDivisorEnumerator2 itr(*this, multiplier, t);
    20542433  if( !itr.Reset() )
     
    20722451  if (__DEBUG__ && (syzterm != NULL))
    20732452  {
    2074     const poly m = L->m[c];
    2075 
    2076     assume( m != NULL ); assume( pNext(m) == NULL );
    2077 
    2078     poly lm = p_Mult_mm(leadmonom(syzterm, r), m, r);
    2079 
    2080     poly pr = p_Mult_q( leadmonom(multiplier, r, false), leadmonom(t, r, false), r);
    2081 
    2082     assume( p_EqualPolys(lm, pr, r) );
     2453    const poly m = L->m[c]; assume( m != NULL ); assume( pNext(m) == NULL );
    20832454
    20842455    //  def @@c = leadcomp(syzterm); int @@r = int(@@c);
    20852456    //  def @@product = leadmonomial(syzterm) * L[@@r];
     2457    poly lm = p_Mult_mm( leadmonom(syzterm, r, true), m, r); // !NC :(
     2458    poly pr = p_Mult_q( leadmonom(multiplier, r, true), leadmonom(t, r, false), r); // !NC :(
     2459
     2460    assume( p_EqualPolys(lm, pr, r) );
    20862461
    20872462    p_Delete(&lm, r);
     
    20892464  }
    20902465
     2466#ifndef SING_NDEBUG
     2467  if( __DEBUG__ )
     2468  {
     2469    DebugPrint();
     2470    syz_checker.Verify();
     2471  }
     2472#endif
     2473 
    20912474  const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ &&
    20922475
     
    20982481  while( itr.MoveNext() )
    20992482  {
    2100     const poly p = itr.Current().m_lt;
    2101     const int k  = itr.Current().m_label;
     2483    assume( itr.Current().CheckLT( L ) ); // ???
     2484   
     2485    const poly p = itr.Current().lt(); // ???
     2486    const int k  = itr.Current().label();
    21022487
    21032488    p_ExpVectorSum(q, multiplier, t, r); // q == product == multiplier * t // TODO: do it once?
     
    21182503        }
    21192504#endif
     2505        assume( itr.Current().CheckLT( L ) ); // ???
    21202506        continue;
    21212507      }
     
    21302516      }
    21312517#endif
     2518      assume( itr.Current().CheckLT( L ) ); // ???
    21322519      continue;
    21332520    }
     
    21372524    n_Delete(&n, r);
    21382525
     2526#ifndef SING_NDEBUG
     2527    if( __DEBUG__ )
     2528    {
     2529      DebugPrint();
     2530      syz_checker.Verify();
     2531    }
     2532#endif
     2533   
     2534    assume( itr.Current().CheckLT( L ) ); // ???
    21392535    return q;
    21402536  }
     
    21682564  {
    21692565
    2170     const poly p = (*vit)->m_lt;
    2171     const int k = (*vit)->m_label;
    2172 
    2173     assume( L->m[k] == p );
    2174 
    2175 //    const unsigned long p_sev = (*vit)->m_sev;
     2566    const poly p = (*vit)->lt(); // ??
     2567    const int k = (*vit)->label();
     2568
     2569    assume( L->m[k] == p ); // CheckLT
     2570
     2571//    const unsigned long p_sev = (*vit)->sev();
    21762572//    assume( p_sev == p_GetShortExpVector(p, r) );
    21772573
     
    22262622
    22272623  p_LmFree(q, r);
     2624 
     2625#ifndef SING_NDEBUG
     2626  if( __DEBUG__ )
     2627  {
     2628    DebugPrint();
     2629    syz_checker.Verify();
     2630  }
     2631#endif
    22282632
    22292633  return NULL;
     
    22342638poly CReducerFinder::FindReducer(const poly product, const poly syzterm, const CReducerFinder& syz_checker) const
    22352639{
     2640
     2641#ifndef SING_NDEBUG
     2642  if( __DEBUG__ )
     2643  {
     2644    DebugPrint();
     2645    syz_checker.Verify();
     2646  }
     2647#endif
     2648
    22362649  CDivisorEnumerator itr(*this, product);
    22372650  if( !itr.Reset() )
     
    22392652
    22402653
     2654 
    22412655  const ring& r = m_rBaseRing;
    22422656
     
    22672681  }
    22682682
     2683#ifndef SING_NDEBUG
     2684  if( __DEBUG__ )
     2685  {
     2686    DebugPrint();
     2687    syz_checker.Verify();
     2688  }
     2689#endif
    22692690
    22702691  const BOOLEAN to_check = (syz_checker.IsNonempty()); // __TAILREDSYZ__ &&
     
    22732694
    22742695  if( __DEBUG__ )
    2275     p_SetCoeff0(q, 0, r); // for printing q
     2696    p_SetCoeff0(q, 0, r); // ONLY for printing q
    22762697
    22772698  while( itr.MoveNext() )
    22782699  {
    2279     const poly p = itr.Current().m_lt;
    2280     const int k  = itr.Current().m_label;
     2700    assume( itr.Current().CheckLT( L ) ); // ???
     2701   
     2702    const poly p = itr.Current().lt(); // ??
     2703    const int k  = itr.Current().label();
    22812704
    22822705    p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k]))
     
    22952718        }
    22962719#endif
     2720        assume( itr.Current().CheckLT( L ) ); // ???
    22972721        continue;
    22982722      }
    22992723
    23002724    // while the complement (the fraction) is not reducible by leading syzygies
    2301     if( to_check && syz_checker.IsDivisible(q) )
     2725    if( to_check && syz_checker.IsDivisible(q) ) // ?????
    23022726    {
    23032727#ifndef SING_NDEBUG
     
    23072731      }
    23082732#endif
     2733      assume( itr.Current().CheckLT( L ) ); // ???
    23092734      continue;
    23102735    }
     
    23122737    p_SetCoeff0(q, n_InpNeg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r);
    23132738
     2739    assume( itr.Current().CheckLT( L ) ); // ???
     2740   
     2741#ifndef SING_NDEBUG
     2742    if( __DEBUG__ )
     2743    {
     2744      DebugPrint();
     2745      syz_checker.Verify();
     2746    }
     2747#endif
     2748   
    23142749    return q;
    23152750  }
     
    23512786  for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
    23522787  {
    2353     const poly p = (*vit)->m_lt;
     2788    const poly p = (*vit)->lt(); // ???
    23542789
    23552790    assume( p_GetComp(p, r) == comp );
    23562791
    2357     const int k = (*vit)->m_label;
    2358 
    2359     assume( L->m[k] == p );
    2360 
    2361     const unsigned long p_sev = (*vit)->m_sev;
     2792    const int k = (*vit)->label();
     2793
     2794    assume( L->m[k] == p ); // CheckLT
     2795
     2796    const unsigned long p_sev = (*vit)->sev();
    23622797
    23632798    assume( p_sev == p_GetShortExpVector(p, r) );
     
    24052840  p_LmFree(q, r);
    24062841
     2842#ifndef SING_NDEBUG
     2843  if( __DEBUG__ )
     2844  {
     2845    DebugPrint();
     2846    syz_checker.Verify();
     2847  }
     2848#endif
     2849 
    24072850  return NULL;
    24082851}
  • Singular/dyn_modules/syzextra/syzextra.h

    r196580 r542685e  
    125125  public:
    126126    CLeadingTerm(unsigned int label,  const poly lt, const ring);
    127 
    128   public:
     127    ~CLeadingTerm();
     128
     129  private:
    129130
    130131    const unsigned long m_sev; ///< not short exp. vector
    131         // NOTE/TODO: either of the following should be enough:
     132   
     133    // NOTE/TODO: either of the following should be enough:
    132134    const unsigned int  m_label; ///< index in the main L[] + 1
     135
    133136    const poly          m_lt; ///< the leading term itself L[label-1]
    134137
    135   public:
     138#ifndef SING_NDEBUG
     139    const ring _R;  const poly          m_lt_copy; ///< original copy of lt (only for debug!!!)
     140#endif
     141   
     142
     143  public:
     144   
    136145    bool DivisibilityCheck(const poly product, const unsigned long not_sev, const ring r) const;
    137146    bool DivisibilityCheck(const poly multiplier, const poly t, const unsigned long not_sev, const ring r) const;
    138147
    139   private:
     148    bool CheckLT( const ideal & L ) const;
     149
     150    poly lt() const;   
     151    unsigned long sev() const;
     152    unsigned int label() const;
     153
     154  private:
     155
    140156    // disable the following:
    141157    CLeadingTerm();
     
    181197#ifndef SING_NDEBUG
    182198    void DebugPrint() const;
     199    void Verify() const;
    183200#endif
    184201
Note: See TracChangeset for help on using the changeset viewer.