Macaulay2 Engine
Loading...
Searching...
No Matches
PolynomialList.cpp
Go to the documentation of this file.
1#include "PolynomialList.hpp"
2#include "matrix.hpp"
3#include "matrix-stream.hpp"
4
5namespace newf4 {
6
8{
9 (void) polyCount;
10 mCurrentPoly = -1;
11}
12
14{
16 mCurrentTerm = -1;
18 mValue.push_back(F);
19 mCoefficients.resize(termCount);
20 mValue[mCurrentPoly].mMonomials.resize(termCount);
21 mValue[mCurrentPoly].mComponents.resize(termCount);
22}
23
25{
27 mValue[mCurrentPoly].mComponents[mCurrentTerm] = com;
28 mSparseMonomial.clear();
29 mSparseMonomial.push_back(0); // will be replaced before we lookup monomial in hash table
30}
31
37
39{
40 // add monomial to hash table, place the monomial in mMonomials.
41 mCoefficients[mCurrentTerm] = coefficient;
42 mSparseMonomial[0] = static_cast<int>(mSparseMonomial.size());
43 mValue[mCurrentPoly].mMonomials[mCurrentTerm] = mValue.monomialHashTable().find(MonomialView(mSparseMonomial.data()));
44}
45
47{
48 mValue[mCurrentPoly].mCoefficients = mValue.vectorArithmetic().elementArrayFromContainerOf_mpz_class(mCoefficients);
49 if (mCurrentTerm != mValue[mCurrentPoly].mComponents.size() - 1)
50 throw exc::engine_error("internal error: building PolyList from stream has incorrect number of terms in a polynomial");
51}
52
54{
55 if (mCurrentPoly != mValue.size() - 1)
56 throw exc::engine_error("internal error: building PolyList from stream has incorrect number of polynomials");
57}
58
59} // end namespoace newf4
60
61
62
63// // TODO: write me.
64// template<typename Stream>
65// void polynomialListToStream(const PolynomialList& Fs, Stream& stream)
66// {
67// // TODO: need a better way to transfer coefficients
68// // at least for now: we need a way to get integers from the coefficients
69// // perhaps use to_modp_long. BUT! Need to check that it is correct...
70// }
71
72// void PolynomialListStreamCollector::idealBegin(size_t polyCount)
73// {
74// // mValue.clear();
75// mCurrentPoly = -1;
76// // mValue.resize(polyCount);
77// }
78
79// void PolynomialListStreamCollector::appendPolynomialBegin(size_t termCount)
80// {
81// mCurrentPoly++;
82// mCurrentTerm = -1;
83// mCoefficients.resize(termCount);
84// mValue[mCurrentPoly].mComponents.resize(termCount);
85// mValue[mCurrentPoly].mMonomials.resize(termCount);
86// }
87
88// void PolynomialListStreamCollector::appendTermBegin(Component com)
89// {
90// mCurrentTerm++;
91// mValue[mCurrentPoly].mComponents[mCurrentTerm] = com;
92// mSparseMonomial.push_back(1);
93// }
94
95// void PolynomialListStreamCollector::appendExponent(VarIndex index, Exponent exponent)
96// {
97// // These need to go into an auxilliary std::vector.
98// mSparseMonomial.push_back(index);
99// mSparseMonomial.push_back(exponent);
100// mSparseMonomial[0] += 2; // length field.
101// }
102
103// void PolynomialListStreamCollector::appendTermDone(Coefficient coefficient)
104// {
105// #if 0
106// auto monomindex = mValue.monomialHashTable().find(MonomialView(mSparseMonomial.data()), 0);
107// // TODO
108// mCoefficients.push_back(coefficient); // FIXME
109// // mValue[mCurrentPoly].coeffs[mCurrentTerm] = coefficient; // REPLACE THIS LINE
110// mValue[mCurrentPoly].mMonomials.push_back(monomindex);
111// mSparseMonomial.clear();
112// mSparseMonomial.push_back(1);
113// #endif
114// }
115
116// void PolynomialListStreamCollector::appendPolynomialDone()
117// {
118// if (mCurrentTerm != mValue[mCurrentPoly].mComponents.size() - 1)
119// throw exc::engine_error("internal error: building PolyList from stream has incorrect number of terms in a polynomial");
120// }
121
122// void PolynomialListStreamCollector::idealDone()
123// {
124// if (mCurrentPoly != mValue.size() - 1)
125// throw exc::engine_error("internal error: building PolyList from stream has incorrect number of polynomials");
126// }
127
128// Local Variables:
129// indent-tabs-mode: nil
130// End:
Hash-table-keyed polynomial storage for the new F4.
std::vector< Coefficient > mCoefficients
std::vector< Exponent > mSparseMonomial
void appendPolynomialBegin(size_t termCount)
void appendExponent(VarIndex index, Exponent exponent)
BasicPolyListStreamCollector::VarIndex VarIndex
BasicPolyListStreamCollector::Component Component
BasicPolyListStreamCollector::Coefficient Coefficient
BasicPolyListStreamCollector::Exponent Exponent
void appendTermDone(Coefficient coefficient)
int * exponent
Definition exptable.h:34
MatrixStream — term-by-term streaming construction of a Matrix.
Matrix — the engine's immutable homomorphism F -> G between free modules.