63 int* exp =
new int[M->
n_vars()];
76 coeffs, t->coeff, f->
coeff);
105 for (
int i = 0; i < F->
rank(); i++)
111 int* exp =
new int[M->
n_vars()];
114 for (
int i = 0; i < f.
len; i++)
124 if (last[comp] ==
nullptr)
131 last[comp]->
next = g;
136 for (
int i = 0; i < F->
rank(); i++)
138 if (comps[i] !=
nullptr)
140 vec v = origR->
make_vec(i, comps[i]);
161 auto& thislevel = C.
level(lev);
163 int* exp =
new int[M->
n_vars()];
164 for (
auto i = 0; i < thislevel.size(); ++i)
167 d[0] = thislevel[i].mDegree;
177 deg, totalmonom,
static_cast<int>(S.
mTieBreaker[i]));
197 auto& thislevel = C.
level(lev);
199 int* exp =
new int[M->
n_vars()];
201 for (
auto i = 0; i < thislevel.size(); ++i)
213 deg, totalmonom,
static_cast<int>(S.
mTieBreaker[i]));
228 return zero.to_matrix();
230 auto& thislevel = C.
level(lev);
233 for (
auto i = thislevel.cbegin(); i != thislevel.cend(); ++i, ++j)
238 return result.to_matrix();
261 auto& thislevel = C.
level(lev);
262 int ncols =
static_cast<int>(thislevel.size());
263 int nrows =
static_cast<int>(C.
level(lev - 1).size());
274 int* exp =
new int[M->
n_vars() + 1];
277 for (
auto j1 = thislevel.cbegin(); j1 != thislevel.cend(); ++j1, ++j)
282 for (
int i = 0; i < nrows; i++)
289 for (
int i = 0; i < f.
len; i++)
297 if (g ==
nullptr)
continue;
299 if (last[comp] ==
nullptr)
306 last[comp]->
next = g;
311 for (
int r = 0; r < nrows; r++)
result->set_entry(r, j, comps[r]);
329 auto& thislevel = C.
level(lev);
331 for (
auto p = thislevel.begin();
p != thislevel.end(); ++
p)
333 if (
p->mDegree == degree) n++;
336 auto& prevlevel = C.
level(lev - 1);
337 int* newcomps =
new int[prevlevel.size()];
339 for (
int i = 0; i < prevlevel.size(); i++)
340 if (prevlevel[i].mDegree == degree)
341 newcomps[i] = nextcomp++;
353 for (
auto p = thislevel.begin();
p != thislevel.end(); ++
p)
355 if (
p->mDegree != degree)
continue;
356 auto& f =
p->mSyzygy;
359 for (; i !=
end; ++i)
362 if (newcomps[comp] >= 0)
365 f.coeffs, i.coefficient_index());
366 result->set_entry(newcomps[comp], col, a);
412 int degree = slanted_degree + lev;
415 if (p->mDegree == degree) mNumColumns++;
418 auto& prevlevel = C.
level(lev - 1);
420 for (
int i = 0; i < prevlevel.size(); i++)
439 for (
auto p = thislevel.begin();
p != thislevel.end(); ++
p)
441 if (
p->mDegree !=
mDegree)
continue;
442 auto& f =
p->mSyzygy;
446 for (; i !=
end; ++i)
518 auto& f =
mIter->mSyzygy;
522 for (; i !=
end; ++i)
524 auto comp =
mGenerator.mSchreyerFrame.monoid().get_component(i.monomial());
525 auto new_comp =
mGenerator.mComponentTranslation[comp];
530 mGenerator.mSchreyerFrame.vectorArithmetic().to_modp_long(f.coeffs, i.coefficient_index());
537 using Iter = std::vector<SchreyerFrameTypes::FrameElement>::iterator;
562template<
typename Gen>
565 const Ring* R =
G.ring();
567 for (
auto i =
G.begin(); i !=
G.end(); ++i)
569 for (
int j=i.components().size()-1; j>=0; --j)
577template<
typename RingType,
typename Gen>
580 M.
resize(
G.numRows(),
G.numColumns());
582 for (
auto i =
G.begin(); i !=
G.end(); ++i)
584 for (
int j=0; j<i.components().size(); ++j)
586 M.
ring().set_from_long(M.
entry(i.components()[j], i.column()), i.coefficients()[j]);
591template<
typename RingType,
typename Gen>
594 M.
resize(
G.numColumns(),
G.numRows());
596 for (
auto i =
G.begin(); i !=
G.end(); ++i)
598 for (
int j=0; j<i.components().size(); ++j)
600 M.
ring().set_from_long(M.
entry(i.column(), i.components()[j]), i.coefficients()[j]);
606template<
typename Gen>
613 auto timeA =
timer();
623 auto timeB =
timer();
624 double nsecs =
seconds(timeB - timeA);
631 std::cout <<
" sparse rank = " << rk
632 <<
" time = " << nsecs <<
" sec"
639template<
typename Gen>
642 unsigned int charac =
654 auto timeA =
timer();
655 int rk =
static_cast<int>(a.rank());
656 auto timeB =
timer();
657 double nsecs =
seconds(timeB - timeA);
664 std::cout <<
" dense rank = " << rk
665 <<
" time = " << nsecs <<
" sec"
672template<
typename Gen>
675 unsigned int charac =
687 auto timeA =
timer();
688 int rk =
static_cast<int>(a.rank());
689 auto timeB =
timer();
690 double nsecs =
seconds(timeB - timeA);
697 std::cout <<
" dense rank = " << rk
698 <<
" time = " << nsecs <<
" sec"
710 double nnonzeroD =
static_cast<double>(nnonzero);
711 double nelementsD =
static_cast<double>(
nelements);
712 double frac_nonzero = (
nelements > 0 ? nnonzeroD/nelementsD : 1.0);
716 std::cout <<
" rank(" << lev <<
"," << slanted_degree <<
") size = "
718 <<
" frac non-zero= " << frac_nonzero << std::endl << std::flush;
722 if (frac_nonzero <= .007)
742 return G->minimal_betti(slanted_degree_limit,
744 ERROR(
"expected resolution computed via res(...,FastNonminimal=>true)");
static const int nelements
Legacy RingZZ — a Ring-derived integer ring backed by GMP mpz_t.
M2::ARingRRR — arbitrary-precision real numbers backed by MPFR.
M2::ARingZZGMP — aring integer ring backed straight by GMP mpz_t.
M2::ARingZZpFFPACK — Z/p via FFLAS-FFPACK's Givaro::Modular<double> field.
M2::ARingZZpFlint — Z/p via FLINT's nmod_t precomputed-reciprocal reduction.
Shared base of the aring framework (namespace M2) that unifies the engine's coefficient rings.
Computation * set_stop_conditions(M2_bool always_stop, M2_arrayint degree_limit, int basis_element_limit, int syzygy_limit, int pair_limit, int codim_limit, int subring_limit, M2_bool just_min_gens, M2_arrayint length_limit)
Abstract base for long-running, resumable engine computations (GBComputation, ResolutionComputation,...
ElementType & entry(size_t row, size_t column)
void resize(size_t new_nrows, size_t new_ncols)
const ACoeffRing & ring() const
size_t numColumns() const
const std::vector< long > & coefficients() const
const std::vector< int > & components() const
bool operator!=(const iterator &sentinel) const
iterator(DegreeZeroMapGenerator &D)
std::vector< int > mComponents
bool operator==(const iterator &sentinel) const
std::vector< SchreyerFrameTypes::FrameElement >::iterator Iter
DegreeZeroMapGenerator & mGenerator
std::vector< long > mCoefficients
iterator(DegreeZeroMapGenerator &D, int)
Column iterator over the parent DegreeZeroMapGenerator's degree-zero submap.
std::vector< SchreyerFrameTypes::FrameElement > & mThisLevel
SchreyerFrame & mSchreyerFrame
std::vector< int > mComponentTranslation
friend class DegreeZeroMapGenerator::iterator
const Ring * ring() const
DegreeZeroMapGenerator(SchreyerFrame &C, int slanted_degree, int lev)
View of one cell of a SchreyerFrame as the degree-zero (scalar) part of the differential between two ...
Type-erased owning handle to a dense coefficient vector held by a ConcreteVectorArithmetic<Ring>.
ResolutionComputation subclass that drives the F4 resolution engine (SchreyerFrame + F4Res) from the ...
const Ring * get_ring() const
const_monomial degree(int i) const
Engine-side free module R^n over a Ring.
void gbvector_remove(gbvector *f)
void gbvector_text_out(buffer &o, const FreeModule *F, const gbvector *f, int nterms=-1) const
int gbvector_n_terms(const gbvector *f) const
Polynomial-ring view tuned for the inner loop of classical Buchberger Groebner-basis computations.
virtual void start_computation()
virtual const Matrix * get_initial(int nparts)
Gaussian elimination class. To be rewritten.
wrapper for the FFPACK::ModularBalanced<double> field implementation
aring-style adapter for Z/p with p a word-size prime, backed by FLINT's nmod_* routines.
void set_entry(int r, int c, ring_elem a)
Mutable builder used to assemble an immutable Matrix one column (or one term) at a time.
void to_expvector(const_monomial m, exponents_t result_exp) const
void degree_of_expvector(const T *expvector, monomial result) const
monomial make_one() const
void remove(monomial d) const
const Monoid * degree_monoid() const
void mult(const_monomial m, const_monomial n, monomial result) const
monomial make_new(const_monomial d) const
void from_expvector(const_exponents exp, monomial result) const
Engine-side commutative monomial monoid: variable names, ordering, multidegree machinery,...
static MutableMatrix * zero_matrix(const Ring *R, size_t nrows, size_t ncols, bool dense)
Abstract base class for mutable matrices over an arbitrary engine Ring, the in-place counterpart of t...
virtual GBRing * get_gb_ring() const
virtual const Monoid * getMonoid() const
virtual ring_elem make_flat_term(const ring_elem a, const_monomial m) const =0
virtual gbvector * translate_gbvector_from_vec(const FreeModule *F, const vec v, ring_elem &result_denominator) const =0
Abstract base for the engine's polynomial-ring hierarchy.
static vec to_M2_vec(const ResPolyRing &R, const ResPolynomial &f, const FreeModule *F)
static FreeModule * to_M2_freemodule(const PolynomialRing *R, SchreyerFrame &C, int lev)
static MutableMatrix * to_M2_MutableMatrix(SchreyerFrame &C, const Ring *R, int lev)
static void from_M2_vec(const ResPolyRing &R, const FreeModule *F, vec v, ResPolynomial &result)
static Matrix * to_M2_matrix(SchreyerFrame &C, int lev, const FreeModule *tar, const FreeModule *src)
int max_monomial_size() const
component_index get_component(res_const_packed_monomial m) const
bool from_expvector(res_const_ntuple_monomial e, component_index comp, res_packed_monomial result) const
bool to_expvector(res_const_packed_monomial m, res_ntuple_monomial result, component_index &result_comp) const
int monomial_size(res_const_packed_monomial m) const
const ResMonoid & monoid() const
const VectorArithmetic & vectorArithmetic() const
The polynomial-ring view the F4 resolution engine reduces against: coefficient arithmetic plus the en...
std::vector< res_monomial_word > monoms
static void setPolyFromArrays(ResPolynomial &result, int len, ElementArray &coeffs, std::vector< res_monomial_word > &monoms)
Polynomial type used by the F4 resolution engine: parallel coefficient vector and concatenated monomi...
Forward iterator over the terms of a ResPolynomial.
virtual FreeModule * make_FreeModule() const
vec make_vec(int r, ring_elem a) const
virtual ring_elem from_long(long n) const =0
virtual const PolynomialRing * cast_to_PolynomialRing() const
long characteristic() const
void add_vec_to(vec &v, vec &w) const
int rankUsingDenseMatrixFlint(Gen &D, bool transposed=true)
int rankUsingSparseMatrix(Gen &D)
int rank(int slanted_degree, int lev)
const ResMonoid & monoid() const
std::vector< FrameElement > & level(int lev)
const ResPolyRing & ring() const
double timeComputeSparseRanks
const VectorArithmetic & vectorArithmetic() const
int rankUsingDenseMatrix(Gen &D, bool transposed=true)
ResSchreyerOrder & schreyerOrder(int lev)
State container for the in-progress free resolution built by the F4 resolution engine.
ElementArray allocateElementArray(ComponentIndex nelems) const
Create a coefficient vector with room for nelems coefficients.
ring_elem ringElemFromElementArray(const ElementArray &coeffs, int index) const
void from_ring_elem(ElementArray &coeffs, ring_elem numer, ring_elem denom_not_used_except_QQ) const
const Ring * ring() const
Two SimpleARing-style coefficient adapters: CoefficientRingZZp and CoefficientRingR.
Abstract Computation base class — stop-condition machinery for incremental engine work.
DMat<ACoeffRing> — dense-matrix template plus the umbrella that wires in every per-ring specialisatio...
Engine error-reporting primitives: ERROR, INTERNAL_ERROR, error, error_message.
namespace exc — internal C++ exception types and the TRY / CATCH macro pair.
FreeModule — finite-rank free module R^n, the type-level anchor for every Matrix.
GaussElimComputation — Gaussian elimination GB / submodule strategy over a field.
GBRing and gbvector — the GB-tuned polynomial-ring view used by classical Buchberger code.
Engine-boundary C API for Gröbner basis, resolution, and Hilbert-series computations.
VALGRIND_MAKE_MEM_DEFINED & result(result)
Engine-to-interpreter type vocabulary across the C++ / .dd boundary.
Engine TBB shim — single point of inclusion for every parallel primitive.
Templated DMat<R> linear algebra: LU, rank, determinant, solve, inverse, nullSpace.
MutableMatrix — abstract base of every mutable matrix the engine hands across the boundary.
MatrixConstructor — the mutable builder that produces an immutable Matrix.
Matrix — the engine's immutable homomorphism F -> G between free modules.
Monoid — variable count, naming, grading, and monomial order of a polynomial ring.
our_new_delete — per-class opt-in routing of new / delete through bdwgc.
PolynomialRing — abstract polynomial-ring base, the engine's most-reused class.
F4ResComputation — top-level Schreyer-frame F4 free-resolution driver.
M2_arrayint rawMinimalBetti(Computation *C, M2_arrayint slanted_degree_limit, M2_arrayint length_limit)
Matrix * matrixFromSparseMatrixGenerator(Gen &G)
void setDMatFromSparseMatrixGeneratorTransposed(Gen &G, DMat< RingType > &M)
void setDMatFromSparseMatrixGenerator(Gen &G, DMat< RingType > &M)
Conversion layer between engine Matrix / vec types and the F4-resolution internal types.
ResMonoid dispatcher — single typedef switch between ResMonoidDense and ResMonoidSparse.
Typed-monomial vocabulary shared by ResMonoid, ResPolyRing, SchreyerFrame, and F4Res.
ResPolyRing and ResPolynomial — resolution-tuned polynomial-ring view and value type.
SchreyerFrame — in-progress representation of a free resolution organised by (level,...
ResSchreyerOrder — per-free-module-summand data implementing the Schreyer order on the next level.
Ring — the legacy abstract base class for every coefficient and polynomial ring.
TermIterator< Nterm > end(Nterm *)
Singly linked-list node carrying one term of a polynomial-ring element.
std::vector< res_packed_monomial > mTotalMonom
std::vector< component_index > mTieBreaker
Per-level Schreyer-order data attached to a SchreyerFrame::Level.
std::chrono::steady_clock::time_point timer()
double seconds(DurationType time_diff)
Inline std::chrono::steady_clock wrappers and elapsed-time conversion helpers.