63 #ifndef RTIMER_BENCHMARKING 64 # define RTIMER_BENCHMARKING 0 95 assume( _IsBucketEmpty(bt) );
96 assume( r == _GetBucketRing(bt) );
105 assume( _IsBucketEmpty(bt) );
190 return ((
int)(
long)(
atGet(rootRingHdl, attribute,
INT_CMD, (
void*)def)));
197 #if (defined(HAVE_QSORT_R) && (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || defined __FreeBSD__ || defined __BSD__ || defined OpenBSD3_1 || defined OpenBSD3_9)) 198 static int cmp_c_ds(
void *
R,
const void *p1,
const void *
p2){
199 #elif (defined(HAVE_QSORT_R) && (defined _GNU_SOURCE || defined __GNU__ || defined __linux__)) 200 static int cmp_c_ds(
const void *p1,
const void *p2,
void *
R){
202 static int cmp_c_ds(
const void *p1,
const void *p2){
void *R =
currRing;
208 const ring
r = (
const ring) R;
229 const int OPT__DEBUG = 0;
260 PrintS(
"cmp_c_ds: a & b have the same comp & deg! ");
PrintLn();
336 static void writeLatexTerm(
const poly t,
const ring r,
const bool bCurrSyz =
true,
const bool bLTonly =
true)
364 PrintS( writePlus?
" + 0" :
" 0 " ); writePlus =
TRUE; writeMult =
TRUE;
391 const short N =
rVar(r);
395 for (
short i = 0;
i <
N;
i++)
421 writePlus = writePlus || wrotePP;
422 writeMult = writeMult || wrotePP;
436 Print(
" \\\\GEN{%ld} ", comp);
438 Print(
" \\\\GENP{%ld} ", comp);
444 PrintS( writePlus?
" + 1 " :
" 1 " );
450 }
while( (!bLTonly) && (p !=
NULL) );
462 memcpy(np->exp, p->exp, r->ExpL_Size*
sizeof(
long));
518 newid->m[
i] =
p_Tail( id->m[
i], r );
529 const int sizeNew =
IDELEMS(
id);
531 #if ( (defined(HAVE_QSORT_R)) && (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || defined __FreeBSD__ || defined __BSD__ || defined OpenBSD3_1 || defined OpenBSD3_9) ) 532 #define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, r, cmp) 533 #elif ( (defined(HAVE_QSORT_R)) && (defined _GNU_SOURCE || defined __GNU__ || defined __linux__)) 534 #define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, cmp, r) 536 #define qsort_my(m, s, ss, r, cmp) qsort(m, s, ss, cmp) 550 id_Delete(const_cast<ideal*>(&m_idTails), m_rBaseRing);
559 if( m_spoly_bucket !=
NULL )
562 m_spoly_bucket =
NULL;
565 for( TCache::iterator it = m_cache.begin(); it != m_cache.end(); it++ )
569 for(TP2PCache::iterator vit = T.begin(); vit != T.end(); vit++ )
571 p_Delete( (&(vit->second)), m_rBaseRing);
572 p_Delete( const_cast<poly*>(&(vit->first)), m_rBaseRing);
591 if(
UNLIKELY(OPT__DEBUG & OPT__TAILREDSYZ) )
592 assume( !IsDivisible(t) );
594 const ring r = m_rBaseRing;
597 if(
LIKELY(OPT__TAILREDSYZ) )
605 CReducersHash::const_iterator itr = m_hash.find(comp);
607 if ( itr == m_hash.end() )
610 assume( itr->first == comp );
612 const bool bIdealCase = (comp == 0);
613 const bool bSyzCheck = syzChecker.
IsNonempty();
615 if(
LIKELY(OPT__TAILREDSYZ && (bIdealCase || bSyzCheck)) )
618 const int N =
rVar(r);
621 for(TReducers::const_iterator vit = v.begin(); (vit != v.end()) && coprime; ++vit )
623 assume( (*vit)->CheckLT( m_L ) );
625 const poly p = (*vit)->lt();
630 for(
int var = N; var > 0; --var )
636 PrintS(
"CReducerFinder::PreProcessTerm, 't' is NOT co-prime with the following leading term: \n");
644 if( bSyzCheck && coprime )
654 if( OPT__DEBUG && !coprime)
656 PrintS(
"CReducerFinder::PreProcessTerm, 't' is co-prime with p but may lead to NOT divisible syz.term: \n");
664 assume( p == (*vit)->lt() );
665 assume( (*vit)->CheckLT( m_L ) );
669 if( OPT__DEBUG && coprime )
670 PrintS(
"CReducerFinder::PreProcessTerm, the following 't' is 'co-prime' with all of leading terms! \n");
673 return coprime? 3: 0;
684 const ideal idTails = m_idTails;
687 const ring r = m_rBaseRing;
689 unsigned long pp[4] = {0,0,0,0};
694 PrintS(
"SchreyerSyzygyComputation::SetUpTailTerms(): Tails: \n");
699 for(
int p =
IDELEMS(idTails) - 1;
p >= 0; --
p )
700 for(
poly* tt = &(idTails->m[
p]); (*tt) !=
NULL; )
703 const int k = m_div.PreProcessTerm(t, m_checker);
704 assume( 0 <= k && k <= 3 );
713 Print(
"SchreyerSyzygyComputation::SetUpTailTerms(): PP (%d) the following TT: \n", k);
728 PrintS(
"SchreyerSyzygyComputation::SetUpTailTerms(): Preprocessed Tails: \n");
735 Print(
"(PP/ST: {c: %lu, C: %lu, P: %lu} + %lu)", pp[1], pp[2], pp[3], pp[0]);
736 m_stat[0] += pp [0]; m_stat[1] += pp [1]; m_stat[2] += pp [2]; m_stat[3] += pp [3];
767 Print(
"SchreyerSyzygyComputation Stats: (PP/ST: {c: %lu, C: %lu, P: %lu} + %lu, LOT: %lu, LCM: %lu, ST:%lu, LK: %lu {*: %lu})\n",
768 m_stat[1], m_stat[2], m_stat[3], m_stat[0],
769 m_stat[4], m_stat[5],
771 m_stat[6] + m_stat[7], m_stat[7]
778 const ideal&
id = m_idLeads;
779 const ring& r = m_rBaseRing;
793 const ideal newid =
idInit(1, 0); newid->m[0] =
NULL;
804 const ideal newid =
idInit( (size * (size-1))/2, size);
814 for (
int i =
j - 1;
i >= 0;
i--)
826 for (
int v =
rVar(r);
v > 0;
v--)
886 const ideal&
id = m_idLeads;
887 const ring& r = m_rBaseRing;
899 const ideal newid =
idInit(1, 1); newid->m[0] =
NULL;
911 ideal newid =
idInit( (size * (size-1))/2, size);
921 for (
int i =
j - 1;
i >= 0;
i--)
937 for (
int v =
rVar(r);
v > 0;
v--)
967 number
g =
n_Lcm( lc1, lc2, r->cf );
1037 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1040 const ideal& L = m_idLeads;
1041 const ideal&
T = m_idTails;
1043 const ring& R = m_rBaseRing;
1055 PrintS(
"SchreyerSyzygyComputation::TraverseNF(syz_lead, poly syz_2), \n");
1066 PrintS(
"{ \"proc\": \"TraverseNF\", \"nodelabel\": \"");
1068 PrintS(
"\", \"children\": [");
1074 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1086 PrintS(
"{ \"proc\": \"TraverseNF2\", \"nodelabel\": \"");
1088 PrintS(
"\", \"children\": [");
1103 PrintS(
"], \"noderesult\": \"");
1111 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1122 PrintS(
"], \"noderesult\": \"");
1130 PrintS(
"SchreyerSyzygyComputation::TraverseNF(syz_lead, poly syz_2), ==>>> \n");
1137 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1146 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1152 const ideal& L = m_idLeads;
1153 const ideal&
T = m_idTails;
1155 ideal& TT = m_syzTails;
1156 const ring& R = m_rBaseRing;
1162 if( m_spoly_bucket ==
NULL )
1173 Print(
"\n{ \"syzygylayer\": \"%d\", \"hybridnf\": \"%d\", \"diagrams\": \n[", OPT__SYZNUMBER, OPT__HYBRIDNF );
1177 if( m_syzLeads ==
NULL )
1183 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: t: %d, r: %d\n", r, t, r);
1190 if(
UNLIKELY(OPT__PROT & RTIMER_BENCHMARKING) )
1193 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: dt: %d, dr: %d\n",
getRTimer(), t, r);
1200 ideal& LL = m_syzLeads;
1205 if( size == 1 && LL->m[0] ==
NULL )
1214 const bool method = (OPT__HYBRIDNF == 1);
1219 if(
LIKELY(!OPT__IGNORETAILS) )
1227 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): t: %d, r: %d\n", r, t, r);
1234 if(
UNLIKELY(OPT__PROT & RTIMER_BENCHMARKING) )
1237 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): dt: %d, dr: %d\n",
getRTimer(), t, r);
1247 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: t: %d, r: %d\n", r, t, r);
1252 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1256 for(
int k = size - 1;
k >= 0; --
k )
1281 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1289 nf = TraverseNF(a, a2);
1292 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1305 if(
UNLIKELY( OPT__DEBUG && (vp !=
NULL) && ! OPT__TREEOUTPUT ) )
1307 Warn(
"SchreyerSyzygyComputation::ComputeSyzygy: failed syzygy property for syzygy [%d], non-zero image is as follows: ",
k);
1310 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: Wrong syzygy is as follows: ");
1314 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: Testing with the other method");
1319 s = TraverseNF(a, a2);
1322 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: The other method gives the following syzygy: ");
1329 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: .... which is correct!!! ");
1332 Warn(
"SchreyerSyzygyComputation::ComputeSyzygy: failed to compute syzygy tail[%d] with both methods!!! Non-zero image (2nd) is as follows: ",
k);
1337 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1343 if(
UNLIKELY( OPT__PROT && (vp !=
NULL) ) )
Warn(
"ERROR: SyzCheck failed, wrong tail: [%d]\n\n",
k);
1349 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1354 if(
UNLIKELY( OPT__PROT & RTIMER_BENCHMARKING ) )
1357 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: dt: %d, dr: %d\n",
getRTimer(), t, r);
1378 if(
UNLIKELY(bComputeSecondTerms) )
1386 assume( !OPT__LEAD2SYZ );
1388 m_syzLeads = Compute1LeadingSyzygyTerms();
1395 if (
LIKELY( OPT__TAILREDSYZ && !OPT__IGNORETAILS && (
IDELEMS(m_syzLeads) > 0) && !((
IDELEMS(m_syzLeads) == 1) && (m_syzLeads->m[0] ==
NULL)) ) )
1398 m_checker.Initialize(m_syzLeads);
1402 const ring& r = m_rBaseRing;
1403 PrintS(
"SchreyerSyzygyComputation::ComputeLeadingSyzygyTerms: \n");
1404 PrintS(
"m_syzLeads: \n");
1405 dPrint(m_syzLeads, r, r, 0);
1406 PrintS(
"m_checker.Initialize(m_syzLeads) => \n");
1407 m_checker.DebugPrint();
1410 assume( m_checker.IsNonempty() );
1413 if(
UNLIKELY( OPT__PROT ) )
Print(
"(L%dS:%d)", bComputeSecondTerms ? 2 : 1,
IDELEMS(m_syzLeads));
1419 assume( !OPT__IGNORETAILS );
1421 const ideal& L = m_idLeads;
1422 const ideal&
T = m_idTails;
1423 const ring& r = m_rBaseRing;
1431 PrintS(
"SchreyerSyzygyComputation::SchreyerSyzygyNF(syz_lead, poly syz_2), \n");
1433 dPrint(syz_lead, r, r, 0);
1443 PrintS(
"\", \"children\": [");
1448 const int rr =
p_GetComp(syz_lead, r) - 1;
1454 syz_2 = m_div.FindReducer(syz_lead, L->m[rr], syz_lead, m_checker);
1470 syz_2 = m_div.FindReducer(aa, syz_lead, m_checker);
1489 if( m_spoly_bucket ==
NULL )
1523 poly t = m_div.FindReducer(spoly,
NULL, m_checker);
1546 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[4];
1559 if( m_spoly_bucket ==
NULL )
1573 PrintS(
"SchreyerSyzygyComputation::SchreyerSyzygyNF(syz_lead, poly syz_2) =>>> \n");
1595 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1598 const ring& r = m_rBaseRing;
1606 return ComputeImage(multiplier, tail);
1609 TCache::iterator top_itr = m_cache.find(tail);
1611 if ( top_itr != m_cache.end() )
1613 assume( top_itr->first == tail );
1617 TP2PCache::iterator itr = T.find(multiplier);
1619 if( itr != T.end() )
1623 if( itr->second ==
NULL )
1630 PrintS(
"{ \"proc\": \"TTLookup\", \"nodelabel\": \"");
1649 Print(
"\"recale\": \"%s\", ", s);
1653 if(
UNLIKELY( OPT__PROT ) ) ++ m_stat[7];
1658 if(
UNLIKELY( OPT__PROT ) ) ++ m_stat[6];
1666 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1676 Print(
"{ \"proc\": \"TTStore%d\", \"nodelabel\": \"", tail + 1);
writeLatexTerm(multiplier, r,
false);
Print(
" \\\\GEN{%d}\", \"children\": [", tail + 1);
1681 const poly p = ComputeImage(multiplier, tail);
1688 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[8];
1692 T.insert( TP2PCache::value_type(
myp_Head(multiplier, (p==
NULL), r), p) );
1700 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1710 Print(
"{ \"proc\": \"TTStore%d\", \"nodelabel\": \"", 0);
writeLatexTerm(multiplier, r,
false);
Print(
" \\\\GEN{%d}\", \"children\": [", tail + 1);
1713 const poly p = ComputeImage(multiplier, tail);
1720 if(
UNLIKELY( OPT__PROT ) ) ++ m_stat[8];
1722 T.insert( TP2PCache::value_type(
myp_Head(multiplier, (p==
NULL), r), p) );
1724 m_cache.insert( TCache::value_type(tail, T) );
1730 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1738 const ring& r = m_rBaseRing;
1745 const poly t = m_idTails->m[tail];
1751 PrintS(
"{ \"proc\": \"ComputeImage\", \"nodelabel\": \"");
1753 Print(
" \\\\GEN{%d}\", \"edgelabel\": \"", tail + 1);
1755 PrintS(
"\", \"children\": [");
1777 assume( !OPT__IGNORETAILS );
1779 const ideal& L = m_idLeads;
1780 const ideal&
T = m_idTails;
1781 const ring& r = m_rBaseRing;
1791 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1794 if(
UNLIKELY( !( (!OPT__TAILREDSYZ) || m_lcm.Check(multiplier) )) )
1796 if(
UNLIKELY(OPT__TAILREDSYZ && OPT__PROT) )
1840 if(
UNLIKELY( OPT__TREEOUTPUT & 0 ) )
1842 Print(
"{ \"proc\": \"TTPoly\", \"nodelabel\": \"");
writeLatexTerm(multiplier, r,
false);
Print(
" * \\\\ldots \", \"children\": [");
1877 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1880 if(
UNLIKELY( OPT__TREEOUTPUT & 0 ) )
1896 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1899 assume( !OPT__IGNORETAILS );
1901 const ideal& L = m_idLeads;
1902 const ideal&
T = m_idTails;
1903 const ring& r = m_rBaseRing;
1917 if( (!OPT__TAILREDSYZ) || m_lcm.Check(multiplier) )
1920 s = m_div.FindReducer(multiplier, term4reduction, syztermCheck, m_checker);
1927 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[4];
1943 s = m_div.FindReducer(product, syztermCheck, m_checker);
1950 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[4];
1964 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1969 if(
UNLIKELY( OPT__TAILREDSYZ && OPT__PROT) )
1997 PrintS(
"\", \"children\": [");
2004 PrintS(
"], \"noderesult\": \"");
2008 if( syztermCheck !=
NULL )
2010 PrintS(
", \"syztermCheck\":\"" );
2024 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
2033 OPT__DEBUG(
atGetInt(rootRingHdl,
"DEBUG", 0) ),
2034 OPT__LEAD2SYZ(
atGetInt(rootRingHdl,
"LEAD2SYZ", 0) ),
2035 OPT__TAILREDSYZ(
atGetInt(rootRingHdl,
"TAILREDSYZ", 1) ),
2036 OPT__HYBRIDNF(
atGetInt(rootRingHdl,
"HYBRIDNF", 0) ),
2037 OPT__IGNORETAILS(
atGetInt(rootRingHdl,
"IGNORETAILS", 0) ),
2038 OPT__SYZNUMBER(
atGetInt(rootRingHdl,
"SYZNUMBER", 0) ),
2039 OPT__TREEOUTPUT(
atGetInt(rootRingHdl,
"TREEOUTPUT", 0) ),
2040 OPT__SYZCHECK(
atGetInt(rootRingHdl,
"SYZCHECK", 0) ),
2042 OPT__NOCACHING(
atGetInt(rootRingHdl,
"NOCACHING", 0) ),
2043 m_rBaseRing( rootRingHdl->data.uring )
2046 if( OPT__DEBUG & 0 )
2048 PrintS(
"SchreyerSyzygyComputationFlags: \n");
2049 Print(
" DEBUG: \t%d\n", OPT__DEBUG);
2071 , _R(R), m_lt_copy(
myp_Head(_lt, true, R) )
2081 CLeadingTerm::~CLeadingTerm()
2115 for( CReducersHash::const_iterator it = m_hash.begin(); it != m_hash.end(); it++ )
2118 for(TReducers::const_iterator vit = v.begin(); vit != v.end(); vit++ )
2119 delete const_cast<CLeadingTerm*>(*vit);
2134 const ring& R = m_rBaseRing;
2139 const poly a = L->m[
k];
2150 m_L(const_cast<ideal>(L)),
2161 int i=r->VarL_Size - 1;
2162 unsigned long divmask = r->divmask;
2163 unsigned long la, lb;
2165 if (r->VarL_LowIndex >= 0)
2167 i += r->VarL_LowIndex;
2171 lb = b->exp[
i] + c->exp[
i];
2173 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
2180 while (i>=r->VarL_LowIndex);
2186 la = a->exp[r->VarL_Offset[
i]];
2187 lb = b->exp[r->VarL_Offset[
i]] + c->exp[r->VarL_Offset[
i]];
2189 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
2208 return ( L->m[label()] == lt() );
2258 if (sev() & not_sev)
2276 CReducerFinder::CReducersHash::const_iterator
m_itr;
2277 CReducerFinder::TReducers::const_iterator m_current,
m_finish;
2288 m_itr(), m_current(), m_finish(),
2297 if( OPT__DEBUG ) m_reds.Verify();
2305 m_itr = m_reds.
m_hash.find(m_comp);
2307 if( m_itr == m_reds.
m_hash.end() )
2310 assume( m_itr->first == m_comp );
2312 m_current = (m_itr->second).begin();
2313 m_finish = (m_itr->second).end();
2315 if (m_current == m_finish)
2325 assume( m_current != m_finish );
2327 return *(*m_current);
2332 assume( m_current != m_finish );
2340 for( ; m_current != m_finish; ++m_current )
2342 assume( Current().CheckLT( m_reds.
m_L ) );
2344 if( Current().DivisibilityCheck(m_product, m_not_sev,
m_rBaseRing) )
2349 Print(
"CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().label());
2354 assume( Current().CheckLT( m_reds.
m_L ) );
2357 assume( Current().CheckLT( m_reds.
m_L ) );
2361 assume( m_current == m_finish );
2373 if( OPT__DEBUG ) Verify();
2426 void CReducerFinder::Verify()
const 2430 for( CReducersHash::const_iterator it =
m_hash.begin(); it !=
m_hash.end(); it++)
2434 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
2438 const poly p = (*vit)->lt();
2440 const unsigned long p_sev = (*vit)->sev();
2445 const int k = (*vit)->label();
2455 void CReducerFinder::DebugPrint()
const 2459 for( CReducersHash::const_iterator it =
m_hash.begin(); it !=
m_hash.end(); it++)
2461 Print(
"Hash Key: %ld, Values: \n", it->first);
2464 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
2468 const int k = (*vit)->label();
2469 const poly p = (*vit)->lt();
2475 const unsigned long p_sev = (*vit)->sev();
2499 CReducerFinder::CReducersHash::const_iterator
m_itr;
2500 CReducerFinder::TReducers::const_iterator m_current,
m_finish;
2508 m_multiplier(m), m_term(t),
2511 m_itr(), m_current(), m_finish(),
2528 if( OPT__DEBUG ) m_reds.Verify();
2536 m_itr = m_reds.
m_hash.find(m_comp);
2538 if( m_itr == m_reds.
m_hash.end() )
2541 assume( m_itr->first == m_comp );
2543 m_current = (m_itr->second).begin();
2544 m_finish = (m_itr->second).end();
2546 if (m_current == m_finish)
2555 assume( m_current != m_finish );
2557 return *(*m_current);
2562 assume( m_current != m_finish );
2571 for( ; m_current != m_finish; ++m_current )
2573 assume( Current().CheckLT( m_reds.
m_L ) );
2575 if( Current().DivisibilityCheck(m_multiplier, m_term, m_not_sev,
m_rBaseRing) )
2580 Print(
"CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().label());
2585 assume( Current().CheckLT( m_reds.
m_L ) );
2589 assume( Current().CheckLT( m_reds.
m_L ) );
2593 assume( m_current == m_finish );
2607 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
2625 if (syzterm !=
NULL)
2648 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
2678 if (syzterm !=
NULL && (k == c))
2684 PrintS(
"_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
2685 dPrint(syzterm, r, r, 0);
2698 PrintS(
"_FindReducer::Test LS: q is divisible by LS[?] !:((: ");
2719 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
2816 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
2831 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
2848 if (syzterm !=
NULL)
2855 const poly m = L->m[c];
2869 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
2891 if (syzterm !=
NULL && (k == c))
2897 PrintS(
"_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
2898 dPrint(syzterm, r, r, 0);
2911 PrintS(
"_FindReducer::Test LS: q is divisible by LS[?] !:((: ");
2929 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
3026 if( OPT__DEBUG ) { Verify(); syz_checker.Verify(); }
3052 for(
int k = l - 1;
k >= 0;
k-- )
3056 for (
unsigned int j =
m_N;
j > 0;
j--)
3075 for (
unsigned int j =
m_N;
j > 0;
j--)
3088 template class std::vector<bool>;
3089 template class std::vector<CLeadingTerm const*>;
3090 template class std::map< CReducerFinder::TComponentKey, CReducerFinder::TReducers >;
3092 template class std::map<TCacheKey, TCacheValue, struct CCacheCompare>;
3093 template class std::map<int, TP2PCache>;
3095 template class std::stack <sBucket_pt>;
void kBucketClear(kBucket_pt bucket, poly *p, int *length)
Computation attribute storage.
BOOLEAN kbTest(kBucket_pt bucket)
Tests.
const unsigned long m_not_sev
const unsigned int m_label
index in the main L[] + 1
const CanonicalForm int s
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
const CReducerFinder & m_reds
const CLeadingTerm & Current() const
static poly p_LmDeleteAndNext(poly p, const ring r)
SBucketFactory & m_factory
poly SchreyerSyzygyNF(const poly syz_lead, poly syz_2=NULL) const
Main HybridNF == 1: poly reduce + LOT + LCM?
const int OPT__HYBRIDNF
Use the usual NF's S-poly reduction while dropping lower order terms 2 means - smart selection! ...
const int OPT__SYZCHECK
CheckSyzygyProperty: TODO.
Compatiblity layer for legacy polynomial operations (over currRing)
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
static poly p_Mult_mm(poly p, poly m, const ring r)
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Detailed print for debugging.
const poly m_lt
the leading term itself L[label-1]
CReducerFinder(const ideal L, const SchreyerSyzygyComputationFlags &flags)
goes over all leading terms
BOOLEAN p_DebugLmDivisibleByNoComp(poly a, poly b, ring r)
std::vector< const CLeadingTerm * > TReducers
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static short rVar(const ring r)
#define rVar(r) (r->N)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static poly pp_Mult_mm(poly p, poly m, const ring r)
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
CDivisorEnumerator2(const CReducerFinder &self, const poly m, const poly t)
static long p_Totaldegree(poly p, const ring r)
poly FindReducer(const poly multiplier, const poly monom, const poly syzterm, const CReducerFinder &checker) const
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
unsigned long sev() const
CDivisorEnumerator(const CReducerFinder &self, const poly product)
void PrintStats() const
print statistics about the used heuristics
#define UNLIKELY(expression)
#define LIKELY(expression)
#define omTypeAllocBin(type, addr, bin)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
CReducerFinder::CReducersHash::const_iterator m_itr
#define BEGIN_NAMESPACE_SINGULARXX
Bucket getBucket(const ring r, const bool remove=true)
ideal Compute2LeadingSyzygyTerms()
leading + second terms
static void p_LmFree(poly p, ring)
static FORCE_INLINE void n_WriteLong(number n, const coeffs r)
write to the output buffer of the currently used reporter
poly kBucketExtractLm(kBucket_pt bucket)
static poly p_Copy(poly p, const ring r)
returns a copy of p
poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const
TODO: save shortcut (syz: |-.->) LM(m) * "t" -> ? ???
const int OPT__TAILREDSYZ
Reduce syzygy tails wrt the leading syzygy terms.
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
void ComputeSyzygy()
The main driver function: computes.
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
poly TraverseNF(const poly syz_lead, const poly syz_2=NULL) const
Coefficient rings, fields and other domains suitable for Singular polynomials.
void kBucketDestroy(kBucket_pt *bucket_pt)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
const CanonicalForm CFMap CFMap & N
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
CLCM(const ideal &L, const SchreyerSyzygyComputationFlags &flags)
#define p_SetRingOfLm(p, r)
SBucketWrapper(const ring r, SBucketFactory &factory)
bool CheckLT(const ideal &L) const
void sBucketDestroy(sBucket_pt *bucket)
The main handler for Singular numbers which are suitable for Singular polynomials.
void StringSetS(const char *st)
#define END_NAMESPACE_SINGULARXX
static poly pp_Mult_qq(poly p, poly q, const ring r)
static void _DestroyBucket(Bucket &bt)
we only expect empty buckets to be left at the end for destructor bt will be set to NULL ...
#define pp_Test(p, lmRing, tailRing)
bool DivisibilityCheck(const poly multiplier, const poly t, const unsigned long not_sev, const ring r) const
as DivisibilityCheck(multiplier * t, ...) for monomial 'm' and a module term 't'
void CleanUp()
Clean up all the accumulated data.
sBucket_pt sBucketCreate(const ring r)
#define BEGIN_NAMESPACE_NONAME
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
CReducerFinder::TReducers::const_iterator m_finish
poly TraverseTail(poly multiplier, const int tail) const
High level caching function!!!
void SetUpTailTerms()
Convert the given ideal of tails into the internal representation (with reducers!) Preprocess m_idTai...
void ComputeLeadingSyzygyTerms(bool bComputeSecondTerms=true)
Computes Syz(leads) or only LEAD of it. The result is stored into m_syzLeads.
static int p_LmCmp(poly p, poly q, const ring r)
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
ideal Compute1LeadingSyzygyTerms()
just leading terms
void PrintS(const char *s)
static char * rRingVar(short i, const ring r)
static poly p_Mult_nn(poly p, number n, const ring r)
SBucketFactory::Bucket Bucket
void Add(poly p, const int l)
adds p to the internal bucket destroys p, l == length(p)
static BOOLEAN p_LmShortDivisibleByNoComp(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
#define p_LmCheckPolyRing1(p, r)
void Initialize(const ideal L)
static unsigned pLength(poly a)
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
const CReducerFinder & m_reds
const unsigned int m_N
number of ring variables
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
const unsigned long m_sev
not short exp. vector
static FORCE_INLINE number n_Lcm(number a, number b, const coeffs r)
in Z: return the lcm of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
bool Check(const poly m) const
const CLeadingTerm & Current() const
static void p_Delete(poly *p, const ring r)
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
ring sBucketGetRing(const sBucket_pt bucket)
Returns bucket ring.
unsigned long p_GetShortExpVector(const poly p, const ring r)
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define p_LmEqual(p1, p2, r)
const Variable & v
< [in] a sqrfree bivariate poly
static void p_ExpVectorDiff(poly pr, poly p1, poly p2, const ring r)
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
static BOOLEAN rField_is_Ring(const ring r)
#define FROM_NAMESPACE(a, s)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
void kBucket_Plus_mm_Mult_pp(kBucket_pt bucket, poly m, poly p, int l)
Bpoly == Bpoly + m*p; where m is a monom Does not destroy p and m assume (l <= 0 || pLength(p) == l) ...
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
const unsigned long m_not_sev
SchreyerSyzygyComputationFlags(idhdl rootRingHdl)
const int OPT__TREEOUTPUT
output lifting tree
poly ComputeImage(poly multiplier, const int tail) const
low level computation...
const ring m_rBaseRing
global base ring
void putBucket(const Bucket &bt, const bool replace=false)
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
static poly p_LmInit(poly p, const ring r)
static void p_Setm(poly p, const ring r)
unsigned int label() const
CReducerFinder::CReducersHash::const_iterator m_itr
bool IsDivisible(const poly q) const
const int OPT__IGNORETAILS
ignore tails and compute the pure Schreyer frame
static void p_LmDelete(poly p, const ring r)
#define p_SetCoeff0(p, n, r)
void Add(poly p)
adds p to the internal bucket destroys p
CReducerFinder::TReducers::const_iterator m_finish
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
static void p_ExpVectorSum(poly pr, poly p1, poly p2, const ring r)
static BOOLEAN p_ExpVectorEqual(poly p1, poly p2, const ring r1, const ring r2)
bool sIsEmpty(const sBucket_pt bucket)
Test whether bucket is empty!?
static poly p_Add_q(poly p, poly q, const ring r)
int status int void size_t count int const void size_t count const char int flags
kBucket_pt kBucketCreate(const ring bucket_ring)
Creation/Destruction of buckets.
static poly p_New(const ring, omBin bin)
void dPrint(const ideal id, const ring lmRing=currRing, const ring tailRing=currRing, const int nTerms=0)
prints an ideal, optionally with details
static poly p_Init(const ring r, omBin bin)
#define SI_RESTORE_OPT1(A)
int PreProcessTerm(const poly t, CReducerFinder &syzChecker) const
is the term to be "preprocessed" as lower order term or lead to only reducible syzygies...
static poly p_Mult_q(poly p, poly q, const ring r)
void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length)