void MatcherMonomial::subMatch(const Monomial & mona,int a, const Monomial & monb, int b, GBList<Match> & result) { if(mona==monb) { Match match; match.firstGBData = a; match.secondGBData = b; match.subsetMatch = true; match.overlapMatch = false; result.push_back(match); } else { int leni = mona.numberOfFactors(); int lenj = monb.numberOfFactors(); if(leni<lenj) { subMonomial INodei(mona,1,0); subMonomial INodej(monb,1,0); const int spread = lenj - leni + 1; INodei.length(leni); INodej.length(leni); for(int k=1;k<=spread;++k) { if(k>1) INodej.incrementStart(); if(INodei==INodej) { Match match; constructMatch(mona,a,monb,b, INodei,INodej,SUBSET_MATCH,match); result.push_back(match); } } } } };
// Mark that fact(i) can not be simplified using fact(j) inline void FactControl::markDone(int i,int j) { if(_done.size()<i) { expandDoneList(i); } GBList<GBList<int> >::iterator ww = _done.begin(); ww.advance(i-1); (*ww).insertIfNotMember(j); };
void _PartialBasisIntoPolynomialContainer(Source & so,Sink & si) { so.shouldBeEnd(); list<Polynomial> aList(run->partialBasis()); GBList<Polynomial> L; const int sz = aList.size(); list<Polynomial>::const_iterator w = aList.begin(); for(int i=1;i<=sz;++i,++w) { L.push_back(*w); }; marker result; result.name("polynomials"); result.num(GBGlobals::s_polynomials().push_back(L)); result.put(si); }; /* _PartialBasisIntoPolynomialContainer */
void MatcherMonomial::overlapMatch(const Monomial & mona,int a, const Monomial & monb,int b, GBList<Match> & result) { int leni = mona.numberOfFactors(); int lenj = monb.numberOfFactors(); int spread = (leni<lenj) ? leni-1 : lenj-1; subMonomial INodei(mona,1,0); subMonomial INodej(monb,1,0); for(int tempk=1;tempk<=spread;++tempk) { INodei.length(0); if(tempk>1) { INodei.decrementStart(); } else { INodei.start(leni); } INodei.length(tempk); INodej.length(tempk); // special meaning here if(INodei==INodej) { Match match; constructMatch(mona,a,monb,b, INodei,INodej,OVERLAP_MATCH,match); result.push_back(match); } } };
void _ConstructSheets(Source & so,Sink & si) { simpleString filename("build_output.tex"); ofstream output(filename.chars()); MyOstream output2(output); #ifdef WANT_MNGRADAPTER PartialGB & pgb = (PartialGB &) ((ManagerAdapter *)run)->PARTIALGB(); Spreadsheet x(pgb,AdmissibleOrder::s_getCurrent()); #endif #ifdef WANT_MNGRSUPER FactControl & fc = (FactControl &) ((MngrSuper *)run)->GetFactBase(); // GBStream << fc; #if 1 const GBList<int> VEC(fc.indicesOfPermanentFacts()); GBList<int>::const_iterator VECB = VEC.begin(); vector<GroebnerRule> vec; const int VECSZ = VEC.size(); vec.reserve(VECSZ); for(int iii=1;iii<=VECSZ;++iii,++VECB) { vec.push_back(fc.fact(*VECB)); }; Sheet1 x(vec,AdmissibleOrder::s_getCurrent()); #else Spreadsheet x(fc,AdmissibleOrder::s_getCurrent()); x.uglyprint(GBStream); #endif TeXSink tex_sink(output2); #if 0 TeX1Display tester(tex_sink,x,AdmissibleOrder::s_getCurrent()); #endif #if 0 list<GroebnerRule> L; copy(x.d_rules.begin(),x.d_rules.end(),back_inserter(L)); TeX2Display tester(tex_sink,L,AdmissibleOrder::s_getCurrent()); #endif #if 1 TeX3Display tester(tex_sink,x,AdmissibleOrder::s_getCurrent()); #endif tester.perform(); #endif GBStream << '\n'; so.shouldBeEnd(); si.noOutput(); os.flush(); output.close(); };
inline void Polynomial::setToZero() { if(_numberOfTerms>0) { _terms.clear(); _numberOfTerms = 0; _totalDegree = 0; } else if(_numberOfTerms<0) errorh(__LINE__); };
inline void FactControl::clearFacts() { clearFactBase(); _facts.clear(); _history.clear(); _extra.clear(); d_numberOfFacts = 0; _done.clear(); };
inline bool Polynomial::one() const { bool result = numberOfTerms() == 1; if(result) { // Bypass the checking on ordering PolynomialIterator j = _terms.begin(); result = (*j).MonomialPart().numberOfFactors()==0 && (*j).CoefficientPart().one(); } return result; };
void transferPartialGBToHelper(GBList<GroebnerRule> & aList) { const pair<int *,int> & L = run->idsForPartialGBRules(); const int num = L.second; if(num>0) { int * p = L.first; for(int j=1;j<=num;++j,++p) { aList.push_back(run->rule(*p)); } } };
inline bool FactControl::isDoneQ(int i,int j) { bool flag = _done.size()>=i; if(!flag) { GBList<GBList<int> >::const_iterator ww = ((const GBList<GBList<int> > &)_done).begin(); ww.advance(i-1); flag = (*ww).Member(j).first(); } return flag; };