63 #ifndef RTIMER_BENCHMARKING 64 # define RTIMER_BENCHMARKING 0 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;
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 extern void id_Delete (ideal*,
const ring);
552 id_Delete(const_cast<ideal*>(&m_idTails), m_rBaseRing);
561 if( m_spoly_bucket !=
NULL )
564 m_spoly_bucket =
NULL;
567 for( TCache::iterator it = m_cache.begin(); it != m_cache.end(); it++ )
571 for(TP2PCache::iterator vit = T.begin(); vit != T.end(); vit++ )
573 p_Delete( (&(vit->second)), m_rBaseRing);
574 p_Delete( const_cast<poly*>(&(vit->first)), m_rBaseRing);
593 if(
UNLIKELY(OPT__DEBUG & OPT__TAILREDSYZ) )
594 assume( !IsDivisible(t) );
596 const ring r = m_rBaseRing;
599 if(
LIKELY(OPT__TAILREDSYZ) )
607 CReducersHash::const_iterator itr = m_hash.find(comp);
609 if ( itr == m_hash.end() )
612 assume( itr->first == comp );
614 const bool bIdealCase = (comp == 0);
615 const bool bSyzCheck = syzChecker.
IsNonempty();
617 if(
LIKELY(OPT__TAILREDSYZ && (bIdealCase || bSyzCheck)) )
620 const int N =
rVar(r);
623 for(TReducers::const_iterator vit = v.begin(); (vit != v.end()) && coprime; ++vit )
625 assume( (*vit)->CheckLT( m_L ) );
627 const poly p = (*vit)->lt();
632 for(
int var = N; var > 0; --var )
638 PrintS(
"CReducerFinder::PreProcessTerm, 't' is NOT co-prime with the following leading term: \n");
646 if( bSyzCheck && coprime )
656 if( OPT__DEBUG && !coprime)
658 PrintS(
"CReducerFinder::PreProcessTerm, 't' is co-prime with p but may lead to NOT divisible syz.term: \n");
666 assume( p == (*vit)->lt() );
667 assume( (*vit)->CheckLT( m_L ) );
671 if( OPT__DEBUG && coprime )
672 PrintS(
"CReducerFinder::PreProcessTerm, the following 't' is 'co-prime' with all of leading terms! \n");
675 return coprime? 3: 0;
686 const ideal idTails = m_idTails;
689 const ring r = m_rBaseRing;
691 unsigned long pp[4] = {0,0,0,0};
696 PrintS(
"SchreyerSyzygyComputation::SetUpTailTerms(): Tails: \n");
701 for(
int p =
IDELEMS(idTails) - 1;
p >= 0; --
p )
702 for(
poly* tt = &(idTails->m[
p]); (*tt) !=
NULL; )
705 const int k = m_div.PreProcessTerm(t, m_checker);
706 assume( 0 <= k && k <= 3 );
715 Print(
"SchreyerSyzygyComputation::SetUpTailTerms(): PP (%d) the following TT: \n", k);
730 PrintS(
"SchreyerSyzygyComputation::SetUpTailTerms(): Preprocessed Tails: \n");
737 Print(
"(PP/ST: {c: %lu, C: %lu, P: %lu} + %lu)", pp[1], pp[2], pp[3], pp[0]);
738 m_stat[0] += pp [0]; m_stat[1] += pp [1]; m_stat[2] += pp [2]; m_stat[3] += pp [3];
769 Print(
"SchreyerSyzygyComputation Stats: (PP/ST: {c: %lu, C: %lu, P: %lu} + %lu, LOT: %lu, LCM: %lu, ST:%lu, LK: %lu {*: %lu})\n",
770 m_stat[1], m_stat[2], m_stat[3], m_stat[0],
771 m_stat[4], m_stat[5],
773 m_stat[6] + m_stat[7], m_stat[7]
780 const ideal&
id = m_idLeads;
781 const ring& r = m_rBaseRing;
795 const ideal newid =
idInit(1, 0); newid->m[0] =
NULL;
806 const ideal newid =
idInit( (size * (size-1))/2, size);
816 for (
int i =
j - 1;
i >= 0;
i--)
828 for (
int v =
rVar(r);
v > 0;
v--)
888 const ideal&
id = m_idLeads;
889 const ring& r = m_rBaseRing;
901 const ideal newid =
idInit(1, 1); newid->m[0] =
NULL;
913 ideal newid =
idInit( (size * (size-1))/2, size);
923 for (
int i =
j - 1;
i >= 0;
i--)
939 for (
int v =
rVar(r);
v > 0;
v--)
969 number
g =
n_Lcm( lc1, lc2, r->cf );
1039 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1042 const ideal& L = m_idLeads;
1043 const ideal&
T = m_idTails;
1045 const ring& R = m_rBaseRing;
1057 PrintS(
"SchreyerSyzygyComputation::TraverseNF(syz_lead, poly syz_2), \n");
1068 PrintS(
"{ \"proc\": \"TraverseNF\", \"nodelabel\": \"");
1070 PrintS(
"\", \"children\": [");
1076 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1088 PrintS(
"{ \"proc\": \"TraverseNF2\", \"nodelabel\": \"");
1090 PrintS(
"\", \"children\": [");
1105 PrintS(
"], \"noderesult\": \"");
1113 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1124 PrintS(
"], \"noderesult\": \"");
1132 PrintS(
"SchreyerSyzygyComputation::TraverseNF(syz_lead, poly syz_2), ==>>> \n");
1139 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1148 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1154 const ideal& L = m_idLeads;
1155 const ideal&
T = m_idTails;
1157 ideal& TT = m_syzTails;
1158 const ring& R = m_rBaseRing;
1164 if( m_spoly_bucket ==
NULL )
1175 Print(
"\n{ \"syzygylayer\": \"%d\", \"hybridnf\": \"%d\", \"diagrams\": \n[", OPT__SYZNUMBER, OPT__HYBRIDNF );
1179 if( m_syzLeads ==
NULL )
1185 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: t: %d, r: %d\n", r, t, r);
1192 if(
UNLIKELY(OPT__PROT & RTIMER_BENCHMARKING) )
1195 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::ComputeLeadingSyzygyTerms: dt: %d, dr: %d\n",
getRTimer(), t, r);
1202 ideal& LL = m_syzLeads;
1207 if( size == 1 && LL->m[0] ==
NULL )
1216 const bool method = (OPT__HYBRIDNF == 1);
1221 if(
LIKELY(!OPT__IGNORETAILS) )
1229 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): t: %d, r: %d\n", r, t, r);
1236 if(
UNLIKELY(OPT__PROT & RTIMER_BENCHMARKING) )
1239 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SetUpTailTerms(): dt: %d, dr: %d\n",
getRTimer(), t, r);
1249 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: t: %d, r: %d\n", r, t, r);
1254 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1258 for(
int k = size - 1;
k >= 0; --
k )
1283 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1291 nf = TraverseNF(a, a2);
1294 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1307 if(
UNLIKELY( OPT__DEBUG && (vp !=
NULL) && ! OPT__TREEOUTPUT ) )
1309 Warn(
"SchreyerSyzygyComputation::ComputeSyzygy: failed syzygy property for syzygy [%d], non-zero image is as follows: ",
k);
1312 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: Wrong syzygy is as follows: ");
1316 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: Testing with the other method");
1321 s = TraverseNF(a, a2);
1324 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: The other method gives the following syzygy: ");
1331 PrintS(
"SchreyerSyzygyComputation::ComputeSyzygy: .... which is correct!!! ");
1334 Warn(
"SchreyerSyzygyComputation::ComputeSyzygy: failed to compute syzygy tail[%d] with both methods!!! Non-zero image (2nd) is as follows: ",
k);
1339 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1345 if(
UNLIKELY( OPT__PROT && (vp !=
NULL) ) )
Warn(
"ERROR: SyzCheck failed, wrong tail: [%d]\n\n",
k);
1351 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1356 if(
UNLIKELY( OPT__PROT & RTIMER_BENCHMARKING ) )
1359 Print(
"\n%% %5d **!TIME4!** SchreyerSyzygyComputation::ComputeSyzygy::SyzygyLift: dt: %d, dr: %d\n",
getRTimer(), t, r);
1380 if(
UNLIKELY(bComputeSecondTerms) )
1388 assume( !OPT__LEAD2SYZ );
1390 m_syzLeads = Compute1LeadingSyzygyTerms();
1397 if (
LIKELY( OPT__TAILREDSYZ && !OPT__IGNORETAILS && (
IDELEMS(m_syzLeads) > 0) && !((
IDELEMS(m_syzLeads) == 1) && (m_syzLeads->m[0] ==
NULL)) ) )
1400 m_checker.Initialize(m_syzLeads);
1404 const ring& r = m_rBaseRing;
1405 PrintS(
"SchreyerSyzygyComputation::ComputeLeadingSyzygyTerms: \n");
1406 PrintS(
"m_syzLeads: \n");
1407 dPrint(m_syzLeads, r, r, 0);
1408 PrintS(
"m_checker.Initialize(m_syzLeads) => \n");
1409 m_checker.DebugPrint();
1412 assume( m_checker.IsNonempty() );
1415 if(
UNLIKELY( OPT__PROT ) )
Print(
"(L%dS:%d)", bComputeSecondTerms ? 2 : 1,
IDELEMS(m_syzLeads));
1421 assume( !OPT__IGNORETAILS );
1423 const ideal& L = m_idLeads;
1424 const ideal&
T = m_idTails;
1425 const ring& r = m_rBaseRing;
1433 PrintS(
"SchreyerSyzygyComputation::SchreyerSyzygyNF(syz_lead, poly syz_2), \n");
1435 dPrint(syz_lead, r, r, 0);
1445 PrintS(
"\", \"children\": [");
1450 const int rr =
p_GetComp(syz_lead, r) - 1;
1456 syz_2 = m_div.FindReducer(syz_lead, L->m[rr], syz_lead, m_checker);
1472 syz_2 = m_div.FindReducer(aa, syz_lead, m_checker);
1491 if( m_spoly_bucket ==
NULL )
1525 poly t = m_div.FindReducer(spoly,
NULL, m_checker);
1548 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[4];
1561 if( m_spoly_bucket ==
NULL )
1575 PrintS(
"SchreyerSyzygyComputation::SchreyerSyzygyNF(syz_lead, poly syz_2) =>>> \n");
1597 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1600 const ring& r = m_rBaseRing;
1608 return ComputeImage(multiplier, tail);
1611 TCache::iterator top_itr = m_cache.find(tail);
1613 if ( top_itr != m_cache.end() )
1615 assume( top_itr->first == tail );
1619 TP2PCache::iterator itr = T.find(multiplier);
1621 if( itr != T.end() )
1625 if( itr->second ==
NULL )
1632 PrintS(
"{ \"proc\": \"TTLookup\", \"nodelabel\": \"");
1651 Print(
"\"recale\": \"%s\", ", s);
1655 if(
UNLIKELY( OPT__PROT ) ) ++ m_stat[7];
1660 if(
UNLIKELY( OPT__PROT ) ) ++ m_stat[6];
1668 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1678 Print(
"{ \"proc\": \"TTStore%d\", \"nodelabel\": \"", tail + 1);
writeLatexTerm(multiplier, r,
false);
Print(
" \\\\GEN{%d}\", \"children\": [", tail + 1);
1683 const poly p = ComputeImage(multiplier, tail);
1690 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[8];
1694 T.insert( TP2PCache::value_type(
myp_Head(multiplier, (p==
NULL), r), p) );
1702 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1712 Print(
"{ \"proc\": \"TTStore%d\", \"nodelabel\": \"", 0);
writeLatexTerm(multiplier, r,
false);
Print(
" \\\\GEN{%d}\", \"children\": [", tail + 1);
1715 const poly p = ComputeImage(multiplier, tail);
1722 if(
UNLIKELY( OPT__PROT ) ) ++ m_stat[8];
1724 T.insert( TP2PCache::value_type(
myp_Head(multiplier, (p==
NULL), r), p) );
1726 m_cache.insert( TCache::value_type(tail, T) );
1732 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1740 const ring& r = m_rBaseRing;
1747 const poly t = m_idTails->m[tail];
1753 PrintS(
"{ \"proc\": \"ComputeImage\", \"nodelabel\": \"");
1755 Print(
" \\\\GEN{%d}\", \"edgelabel\": \"", tail + 1);
1757 PrintS(
"\", \"children\": [");
1779 assume( !OPT__IGNORETAILS );
1781 const ideal& L = m_idLeads;
1782 const ideal&
T = m_idTails;
1783 const ring& r = m_rBaseRing;
1793 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1796 if(
UNLIKELY( !( (!OPT__TAILREDSYZ) || m_lcm.Check(multiplier) )) )
1798 if(
UNLIKELY(OPT__TAILREDSYZ && OPT__PROT) )
1842 if(
UNLIKELY( OPT__TREEOUTPUT & 0 ) )
1844 Print(
"{ \"proc\": \"TTPoly\", \"nodelabel\": \"");
writeLatexTerm(multiplier, r,
false);
Print(
" * \\\\ldots \", \"children\": [");
1879 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1882 if(
UNLIKELY( OPT__TREEOUTPUT & 0 ) )
1898 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1901 assume( !OPT__IGNORETAILS );
1903 const ideal& L = m_idLeads;
1904 const ideal&
T = m_idTails;
1905 const ring& r = m_rBaseRing;
1919 if( (!OPT__TAILREDSYZ) || m_lcm.Check(multiplier) )
1922 s = m_div.FindReducer(multiplier, term4reduction, syztermCheck, m_checker);
1929 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[4];
1945 s = m_div.FindReducer(product, syztermCheck, m_checker);
1952 if(
UNLIKELY(OPT__PROT) ) ++ m_stat[4];
1966 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
1971 if(
UNLIKELY( OPT__TAILREDSYZ && OPT__PROT) )
1999 PrintS(
"\", \"children\": [");
2006 PrintS(
"], \"noderesult\": \"");
2010 if( syztermCheck !=
NULL )
2012 PrintS(
", \"syztermCheck\":\"" );
2026 if( OPT__DEBUG ) { m_div.Verify(); m_checker.Verify(); }
2035 OPT__DEBUG(
atGetInt(rootRingHdl,
"DEBUG", 0) ),
2036 OPT__LEAD2SYZ(
atGetInt(rootRingHdl,
"LEAD2SYZ", 0) ),
2037 OPT__TAILREDSYZ(
atGetInt(rootRingHdl,
"TAILREDSYZ", 1) ),
2038 OPT__HYBRIDNF(
atGetInt(rootRingHdl,
"HYBRIDNF", 0) ),
2039 OPT__IGNORETAILS(
atGetInt(rootRingHdl,
"IGNORETAILS", 0) ),
2040 OPT__SYZNUMBER(
atGetInt(rootRingHdl,
"SYZNUMBER", 0) ),
2041 OPT__TREEOUTPUT(
atGetInt(rootRingHdl,
"TREEOUTPUT", 0) ),
2042 OPT__SYZCHECK(
atGetInt(rootRingHdl,
"SYZCHECK", 0) ),
2044 OPT__NOCACHING(
atGetInt(rootRingHdl,
"NOCACHING", 0) ),
2045 m_rBaseRing( rootRingHdl->data.uring )
2048 if( OPT__DEBUG & 0 )
2050 PrintS(
"SchreyerSyzygyComputationFlags: \n");
2051 Print(
" DEBUG: \t%d\n", OPT__DEBUG);
2073 , _R(R), m_lt_copy(
myp_Head(_lt, true, R) )
2117 for( CReducersHash::const_iterator it = m_hash.begin(); it != m_hash.end(); it++ )
2120 for(TReducers::const_iterator vit = v.begin(); vit != v.end(); vit++ )
2121 delete const_cast<CLeadingTerm*>(*vit);
2136 const ring& R = m_rBaseRing;
2141 const poly a = L->m[
k];
2152 m_L(const_cast<ideal>(L)),
2163 int i=r->VarL_Size - 1;
2164 unsigned long divmask = r->divmask;
2165 unsigned long la, lb;
2167 if (r->VarL_LowIndex >= 0)
2169 i += r->VarL_LowIndex;
2173 lb = b->exp[
i] + c->exp[
i];
2175 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
2182 while (i>=r->VarL_LowIndex);
2188 la = a->exp[r->VarL_Offset[
i]];
2189 lb = b->exp[r->VarL_Offset[
i]] + c->exp[r->VarL_Offset[
i]];
2191 (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)))
2210 return ( L->m[label()] == lt() );
2260 if (sev() & not_sev)
2278 CReducerFinder::CReducersHash::const_iterator
m_itr;
2279 CReducerFinder::TReducers::const_iterator m_current,
m_finish;
2290 m_itr(), m_current(), m_finish(),
2299 if( OPT__DEBUG ) m_reds.
Verify();
2307 m_itr = m_reds.
m_hash.find(m_comp);
2309 if( m_itr == m_reds.
m_hash.end() )
2312 assume( m_itr->first == m_comp );
2314 m_current = (m_itr->second).begin();
2315 m_finish = (m_itr->second).end();
2317 if (m_current == m_finish)
2327 assume( m_current != m_finish );
2329 return *(*m_current);
2334 assume( m_current != m_finish );
2342 for( ; m_current != m_finish; ++m_current )
2344 assume( Current().CheckLT( m_reds.
m_L ) );
2346 if( Current().DivisibilityCheck(m_product, m_not_sev,
m_rBaseRing) )
2351 Print(
"CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().label());
2356 assume( Current().CheckLT( m_reds.
m_L ) );
2359 assume( Current().CheckLT( m_reds.
m_L ) );
2363 assume( m_current == m_finish );
2375 if( OPT__DEBUG )
Verify();
2432 for( CReducersHash::const_iterator it =
m_hash.begin(); it !=
m_hash.end(); it++)
2436 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
2440 const poly p = (*vit)->lt();
2442 const unsigned long p_sev = (*vit)->sev();
2447 const int k = (*vit)->label();
2461 for( CReducersHash::const_iterator it =
m_hash.begin(); it !=
m_hash.end(); it++)
2463 Print(
"Hash Key: %ld, Values: \n", it->first);
2466 for(TReducers::const_iterator vit = reducers.begin(); vit != reducers.end(); vit++ )
2470 const int k = (*vit)->label();
2471 const poly p = (*vit)->lt();
2477 const unsigned long p_sev = (*vit)->sev();
2501 CReducerFinder::CReducersHash::const_iterator
m_itr;
2502 CReducerFinder::TReducers::const_iterator m_current,
m_finish;
2510 m_multiplier(m), m_term(t),
2513 m_itr(), m_current(), m_finish(),
2530 if( OPT__DEBUG ) m_reds.
Verify();
2538 m_itr = m_reds.
m_hash.find(m_comp);
2540 if( m_itr == m_reds.
m_hash.end() )
2543 assume( m_itr->first == m_comp );
2545 m_current = (m_itr->second).begin();
2546 m_finish = (m_itr->second).end();
2548 if (m_current == m_finish)
2557 assume( m_current != m_finish );
2559 return *(*m_current);
2564 assume( m_current != m_finish );
2573 for( ; m_current != m_finish; ++m_current )
2575 assume( Current().CheckLT( m_reds.
m_L ) );
2577 if( Current().DivisibilityCheck(m_multiplier, m_term, m_not_sev,
m_rBaseRing) )
2582 Print(
"CDivisorEnumerator::MoveNext::est LS: q is divisible by LS[%d] !:((, diviser is: ", 1 + Current().label());
2587 assume( Current().CheckLT( m_reds.
m_L ) );
2591 assume( Current().CheckLT( m_reds.
m_L ) );
2595 assume( m_current == m_finish );
2627 if (syzterm !=
NULL)
2680 if (syzterm !=
NULL && (k == c))
2686 Print(
"_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
2687 dPrint(syzterm, r, r, 0);
2700 PrintS(
"_FindReducer::Test LS: q is divisible by LS[?] !:((: ");
2850 if (syzterm !=
NULL)
2857 const poly m = L->m[c];
2893 if (syzterm !=
NULL && (k == c))
2899 Print(
"_FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
2900 dPrint(syzterm, r, r, 0);
2913 PrintS(
"_FindReducer::Test LS: q is divisible by LS[?] !:((: ");
3054 for(
int k = l - 1;
k >= 0;
k-- )
3058 for (
unsigned int j =
m_N;
j > 0;
j--)
3077 for (
unsigned int j =
m_N;
j > 0;
j--)
3090 template class std::vector<bool>;
3091 template class std::vector<CLeadingTerm const*>;
3092 template class std::map< CReducerFinder::TComponentKey, CReducerFinder::TReducers >;
3094 template class std::map<TCacheKey, TCacheValue, struct CCacheCompare>;
3095 template class std::map<int, TP2PCache>;
3097 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
static bool _IsBucketEmpty(const Bucket &bt)
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
poly TraverseNF(const poly syz_lead, const poly syz_2=NULL) const
static poly p_LmDeleteAndNext(poly p, const ring r)
SBucketFactory & m_factory
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'
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.
poly SchreyerSyzygyNF(const poly syz_lead, poly syz_2=NULL) const
Main HybridNF == 1: poly reduce + LOT + LCM?
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 ring _GetBucketRing(const Bucket &bt)
get bucket ring
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
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 short rVar(const ring r)
#define rVar(r) (r->N)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
const CLeadingTerm & Current() const
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)
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!
CDivisorEnumerator(const CReducerFinder &self, const poly product)
#define UNLIKELY(expression)
const poly m_lt_copy
original copy of LEAD(lt) (only for debug!!!)
#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
unsigned long sev() const
static Bucket _CreateBucket(const ring r)
inital allocation for new buckets
kBucket_pt kBucketCreate(ring bucket_ring)
Creation/Destruction of buckets.
#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 int pLength(poly a)
poly kBucketExtractLm(kBucket_pt bucket)
static poly p_Copy(poly p, const ring r)
returns a copy of p
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 ...
const CLeadingTerm & Current() const
Coefficient rings, fields and other domains suitable for Singular polynomials.
bool IsDivisible(const poly q) const
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)
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 ...
poly TraverseTail(poly multiplier, const int tail) const
High level caching function!!!
#define pp_Test(p, lmRing, tailRing)
void CleanUp()
Clean up all the accumulated data.
#define BEGIN_NAMESPACE_NONAME
CReducerFinder::TReducers::const_iterator m_finish
sBucket_pt sBucketCreate(ring r)
static FORCE_INLINE void n_Write(number &n, const coeffs r, const BOOLEAN bShortOut=TRUE)
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)
void PrintStats() const
print statistics about the used heuristics
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
poly ComputeImage(poly multiplier, const int tail) const
low level computation...
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 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)
poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck) const
TODO: save shortcut (syz: |-.->) LM(m) * "t" -> ? ???
static void p_Delete(poly *p, const ring r)
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) ...
unsigned int label() const
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...
bool CheckLT(const ideal &L) const
poly FindReducer(const poly multiplier, const poly monom, const poly syzterm, const CReducerFinder &checker) const
const unsigned long m_not_sev
SchreyerSyzygyComputationFlags(idhdl rootRingHdl)
const int OPT__TREEOUTPUT
output lifting tree
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)
CReducerFinder::CReducersHash::const_iterator m_itr
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)
bool Check(const poly m) const
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
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)
static poly p_Mult_q(poly p, poly q, const ring r)
void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length)
static FORCE_INLINE void n_WriteLong(number &n, const coeffs r)
write to the output buffer of the currently used reporter