Macaulay2 Engine
Loading...
Searching...
No Matches
res-f4.hpp
Go to the documentation of this file.
1// Copyright 2014-2016 Michael E. Stillman
2
3#ifndef _res_f4_hpp_
4#define _res_f4_hpp_
5
53
54#include "VectorArithmetic.hpp"
55#include "f4/monhashtable.hpp"
58#include "monomial-sets.hpp"
59
60#include <cassert>
61
62class SchreyerFrame;
63
65
83class F4Res
84{
85 friend class ResColumnsSorter;
86
87 public:
88 F4Res(SchreyerFrame& res);
89
90 ~F4Res();
91
92 SchreyerFrame& frame() { return mFrame; }
93 const SchreyerFrame& frame() const { return mFrame; }
94 // Constructs the elements of the GB at level 'lev', in the given degree.
95 // The following must have been done:
96 // construct(lev, degree-1)
97 // and
98 // construct(lev-1, degree-1)
99 // NOTE: it is not needed to have done: construct(lev-1,degree)
100 void construct(int lev, int degree);
101
102 const VectorArithmetic& vectorArithmetic() const { return mRing.vectorArithmetic(); }
103 const ResMonoid& monoid() const { return mRing.monoid(); }
104 const ResPolyRing& ring() const { return mRing; }
105 private:
118 struct Row
119 {
121 mLeadTerm; // monomial (level lev-1) giving rise to this row
122 // The following two should have the same length.
123 std::vector<ComponentIndex> mComponents; // indices into mColumns
125 Row() : mLeadTerm(nullptr) {}
126 };
127
129 // Functions for construction //////
131 void resetMatrix(int lev,
132 int degree); // remember to clearMatrix before calling this.
133 void clearMatrix();
135 ComponentIndex processCurrentMonomial(res_packed_monomial thisMonom); // subroutine of processMonomialProduct
138 int& result_sign_if_skew);
139 // if result_sign_if_skew is set to 0, then result is set to -1.
140 void loadRow(Row& r);
141 void reorderColumns();
142 void makeMatrix();
143 void gaussReduce();
144 void gaussReduceRow(int index,
145 ElementArray &dense,
146 bool onlyConstantMaps,
147 const std::vector<bool>& track);
148
149 void debugOutputReducers();
150 void debugOutputColumns();
151 void debugOutputMatrix(std::vector<Row>&);
152 void debugOutputMatrixSparse(std::vector<Row>&);
156 // Data for construct(lev,degree) //
158
160
162
163 // Data used to construct the next matrix
167 // res_packed_monomial mNextMonom;
168
169 std::unique_ptr<const ResMonomialsWithComponent>
170 mSchreyerRes; // Support structure for mHashTable
171 // const ResMonomialsWithComponent* mSchreyerRes; // Support structure for
172 // mHashTable
174 // at level lev-2,
175 // values: indices
176 // into mColumns.
177 // or: -1: means is determined to not need to be a column.
178
179 std::vector<Row> mReducers; // columns: mColumns. This is a square matrix.
180 std::vector<Row>
181 mSPairs; // columns: also mColumns One row per element at (lev,degree).
182 std::vector<long> mSPairComponents; // index into mFrame.level(mThisLevel)
183 std::vector<res_packed_monomial>
184 mColumns; // all the monomials at level lev-2 we need to consider
185 // ResMemoryBlock<res_monomial_word> mMonomSpace; // for monomials stored in this
186 // (lev,degree) in mColumns and
187 // the lead terms in Row.
189};
190
191#endif
192
193// Local Variables:
194// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
195// indent-tabs-mode: nil
196// End:
Coefficient-ring-erased arithmetic dispatcher used by F4, GB, and resolution code.
Type-erased owning handle to a dense coefficient vector held by a ConcreteVectorArithmetic<Ring>.
void debugOutputReducers()
Definition res-f4.cpp:705
void resetMatrix(int lev, int degree)
Definition res-f4.cpp:69
MonomialHashTable< ResMonomialsWithComponent > mHashTable
Definition res-f4.hpp:173
ComponentIndex processMonomialProduct(res_const_packed_monomial m, res_const_packed_monomial n, int &result_sign_if_skew)
Definition res-f4.cpp:154
void gaussReduce()
Definition res-f4.cpp:579
void reorderColumns()
Definition res-f4.cpp:300
F4Res(SchreyerFrame &res)
Definition res-f4.cpp:50
void construct(int lev, int degree)
Definition res-f4.cpp:640
int mThisDegree
Definition res-f4.hpp:165
const VectorArithmetic & vectorArithmetic() const
Definition res-f4.hpp:102
const ResPolyRing & ring() const
Definition res-f4.hpp:104
~F4Res()
Definition res-f4.cpp:64
void debugOutputColumns()
Definition res-f4.cpp:715
friend class ResColumnsSorter
Definition res-f4.hpp:85
int mThisLevel
Definition res-f4.hpp:164
std::unique_ptr< const ResMonomialsWithComponent > mSchreyerRes
Definition res-f4.hpp:170
const SchreyerFrame & frame() const
Definition res-f4.hpp:93
const ResMonoid & monoid() const
Definition res-f4.hpp:103
std::vector< res_packed_monomial > mColumns
Definition res-f4.hpp:184
void debugOutputMatrixSparse(std::vector< Row > &)
Definition res-f4.cpp:726
MonomialMemorySpace mMonomSpace2
Definition res-f4.hpp:188
void makeMatrix()
Definition res-f4.cpp:408
std::vector< Row > mReducers
Definition res-f4.hpp:179
bool findDivisor(res_const_packed_monomial m, res_packed_monomial result)
findDivisor
Definition res-f4.cpp:109
SchreyerFrame & mFrame
Definition res-f4.hpp:159
void gaussReduceRow(int index, ElementArray &dense, bool onlyConstantMaps, const std::vector< bool > &track)
Definition res-f4.cpp:465
const ResPolyRing & mRing
Definition res-f4.hpp:161
void debugOutputMatrix(std::vector< Row > &)
Definition res-f4.cpp:739
void clearMatrix()
Definition res-f4.cpp:76
std::vector< long > mSPairComponents
Definition res-f4.hpp:182
void loadRow(Row &r)
Definition res-f4.cpp:226
void debugOutputSPairMatrix()
Definition res-f4.cpp:750
ComponentIndex processCurrentMonomial(res_packed_monomial thisMonom)
Definition res-f4.cpp:192
void debugOutputReducerMatrix()
Definition res-f4.cpp:749
SchreyerFrame & frame()
Definition res-f4.hpp:92
long mNextReducerToProcess
Definition res-f4.hpp:166
std::vector< Row > mSPairs
Definition res-f4.hpp:181
Bump-pointer arena for monomial storage, backed by a memt::Arena.
The polynomial-ring view the F4 resolution engine reduces against: coefficient arithmetic plus the en...
State container for the in-progress free resolution built by the F4 resolution engine.
Runtime dispatcher that hides the concrete coefficient ring behind a std::variant of ConcreteVectorAr...
VALGRIND_MAKE_MEM_DEFINED & result(result)
MonomialHashTable<ValueType> — open-addressing intern table for F4 and resolution monomials.
MonomialSetFixedSize / MonomialSetVarSize / MonomialCollection* / MonomialMemorySpace — monomial-inte...
ResMemoryBlock<T, NSLAB> — resolution-side templated slab bump allocator.
ResMonoidDense ResMonoid
const res_monomial_word * res_const_packed_monomial
res_monomial_word * res_packed_monomial
ResPolyRing and ResPolynomial — resolution-tuned polynomial-ring view and value type.
int ComponentIndex
std::vector< ComponentIndex > mComponents
Definition res-f4.hpp:123
ElementArray mCoeffs
Definition res-f4.hpp:124
res_packed_monomial mLeadTerm
Definition res-f4.hpp:121