Macaulay2 Engine
Loading...
Searching...
No Matches
res-a1.hpp
Go to the documentation of this file.
1// Copyright 1996. Michael E. Stillman
2
3#ifndef _res_hh_
4#define _res_hh_
5
6#include "style.hpp"
7#include "matrix.hpp"
8#include "monideal.hpp"
9#include "polyring.hpp"
10#include "comp-res.hpp"
11
12#include "res-a1-poly.hpp"
13
14class res_pair;
15class res_degree;
16class res_level;
17class res_comp;
18class res_poly;
19
21// Collection of pairs all of the same degree
22{
23 friend class res_comp;
24
25 res_pair *first; // list of pairs in this degree, no list head
26
27 res_pair *next_new_pair; // sort_pairs will set this to non-null
28 res_pair *next_pair; // set to be first (when?)
29 res_pair *next_gen; // this is a separate list of sorted generators
30
31 int is_sorted; // If set, then the pairs have already been sorted
32 int npairs;
33 int nleft;
35
36 public:
38 : first(nullptr),
39 next_new_pair(nullptr),
40 next_pair(nullptr),
41 next_gen(nullptr),
42 is_sorted(0),
43 npairs(0),
44 nleft(0),
45 nminimal(0)
46 {
47 }
49};
50
52// Collection of pairs all at same syzygy level
53{
54 friend class res_comp;
55
56 VECTOR(res_degree *) bin; // Bins for pairs sorted by (slanted)
57 // degree. So bin[d] refers to elements
58 // of degree low_degree + level + d
59 VECTOR(res_pair *) elems;
60
62 int npairs;
63 int nleft;
65
66 public:
67 res_level() : compare_num_list(nullptr), npairs(0), nleft(0), nminimal(0) {}
68};
69
76{
77 // Base ring and input
80 const Monoid *M;
81 const Ring *K;
82 const Matrix *generator_matrix; // Input matrix of generators, possibly a GB,
83 // possibly not
86
87 // The current state of the computation
88 int n_level; // Current level
89 int n_degree; // Current (slanted) degree
90
91 VECTOR(res_level *) resn; // The resolution itself
92
93 // Degree and length limits, monomial size limit
94 VECTOR(res_pair *) base_components;
95 VECTOR(MonomialIdeal *) search_mi; // Used for new generators only...
96
97 int lodegree; // Base degree
98 int hidegree; // Highest (slanted) degree appearing
99 int length_limit; // May be downsized during the computation, but never
100 // increased.
101
102 int max_degree; // This is the largest degree than can be represented
103 // as a least common multiple. Any higher degree found
104 // will cause the computation to exit with COMP_RESIZE
105
106 // Statistics
109 int nleft;
112
113 // byte sizes for allocating temp exp vectors and monomials on the stack
114 size_t exp_size;
116
118
119 res_pair *elem(int lev, int n) const { return resn[lev]->elems[n]; }
122 res_pair *reduce(resterm *&f, resterm *&fsyz, resterm *&pivot);
123 res_pair *reduce_level_one(resterm *&f, resterm *&fsyz, resterm *&pivot);
124 void reduce_gen(resterm *&f) const;
125 resterm *s_pair(res_pair *fsyz) const;
126
127 enum ComputationStatusCode gens(int deg);
128 enum ComputationStatusCode pairs(int level, int deg);
129 enum ComputationStatusCode reductions(int level, int deg);
130
131 void handle_pair(res_pair *p);
132 void handle_gen(res_pair *p);
133
134 void new_pairs(res_pair *p);
135
136 int sort_value(res_pair *p, const std::vector<int> sort_order) const;
137 int compare_res_pairs(res_pair *f, res_pair *g) const;
139 void sort_res_pairs(res_pair *&p) const;
141 void sort_pairs(int level, int deg);
142
143 int compare_compares(res_pair *f, res_pair *g) const;
145 void sort_compares(res_pair *&p) const;
146 void set_compare_nums(int level, int deg);
147
148 int degree(const res_pair *q) const;
149 void multi_degree(const res_pair *q, monomial result) const;
150
151 res_degree *make_degree_set(int level, int deg);
152 res_degree *get_degree_set(int level, int d) const;
154 res_pair *new_res_pair(int i);
155 res_pair *new_res_pair(int syztype, resterm *f);
156 res_pair *new_res_pair(int syztype, res_pair *first, res_pair *second);
157 void insert_res_pair(int level, res_pair *p);
158
160 // Initiating the computation ///////////////
162 private:
165 void remove_res_level(res_level *lev);
166
167 void initialize(const Matrix *mat, int LengthLimit, int strategy);
168
169 public:
170 res_comp(const Matrix *m, int LengthLimit, int strategy);
171
172 virtual ~res_comp();
173
174 void resize(const Ring *new_ring);
175
176 bool stop_conditions_ok();
177
179 // Performing the calculation ///////////////
181
182 void skeleton_init(VECTOR(res_pair *)& reslevel);
184 int skeleton_maxdegree(const VECTOR(res_pair *)& reslevel);
185 void skeleton_stats(const VECTOR(res_pair *)& reslevel);
186
187 void skeleton(int strategy);
188
189 void start_computation();
190
191 int complete_thru_degree() const;
192
194 // Result matrices of the resolution ////////
196 private:
197 void reduce_minimal(int x, resterm *&f, VECTOR(res_pair *)& elems) const;
198
199 public:
200 const FreeModule *free_of(int i) const;
201 const FreeModule *minimal_free_of(int i) const;
202 Matrix *make(int i) const;
203 Matrix *make_minimal(int i) const;
204
205 const Matrix /* or null */ *get_matrix(int level)
206 {
207 return make_minimal(level);
208 }
209
210 const FreeModule /* or null */ *get_free(int level)
211 {
212 return minimal_free_of(level);
213 }
214
216 // Betti routines and numbers associated ////
217 // with the resolution ////
219 // Betti output is a flattened array of /////
220 // length /////
221 // (high_degree() - low_degree() + 1) /////
222 // * (max_level() + 1) /////
223 // The first row of the betti display is /////
224 // given first, then the second, etc /////
226
227 int n_pairs(int lev, int d) const;
228 int n_left(int lev, int d) const;
229 int n_minimal(int lev, int d) const;
230 int n_monoms(int lev, int d) const;
231
232 int low_degree() const;
233 int high_degree() const;
234 int max_level() const;
235 int regularity() const;
236
241
242 M2_arrayint get_betti(int type) const;
243
245 // Debugging ////////////////////////////////
247
248 void text_out(const res_pair *p) const;
249 void stats() const;
250
251 void text_out(buffer &o, const res_pair *p) const;
252 void text_out(buffer &o) const;
253};
254#endif
255
256// Local Variables:
257// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
258// indent-tabs-mode: nil
259// End:
exponents::ConstExponents const_exponents
Engine-side free module R^n over a Ring.
Definition freemod.hpp:66
Engine-side commutative monomial monoid: variable names, ordering, multidegree machinery,...
Definition monoid.hpp:89
Engine-side monomial ideal: a decision tree of Nmi_nodes storing the (typically minimal) generators b...
Definition monideal.hpp:136
Abstract base for the engine's polynomial-ring hierarchy.
Definition polyring.hpp:96
xxx xxx xxx
Definition ring.hpp:102
size_t exp_size
Definition res-a1.hpp:114
M2_arrayint betti_remaining() const
Definition res-a1.cpp:1224
Matrix * make_minimal(int i) const
Definition res-a1.cpp:1438
void remove_res_level(res_level *lev)
Definition res-a1.cpp:159
int hidegree
Definition res-a1.hpp:98
int n_left(int lev, int d) const
Definition res-a1.cpp:1142
int degree(const res_pair *q) const
Definition res-a1.cpp:273
void sort_compares(res_pair *&p) const
Definition res-a1.cpp:544
res_degree * make_degree_set(int level, int deg)
Definition res-a1.cpp:175
void sort_pairs(int level, int deg)
Definition res-a1.cpp:481
int n_monoms(int lev, int d) const
Definition res-a1.cpp:1165
resterm * s_pair(res_pair *fsyz) const
Definition res-a1.cpp:722
enum ComputationStatusCode reductions(int level, int deg)
Definition res-a1.cpp:1024
int regularity() const
int find_divisor(const_exponents exp, res_pair *&result) const
int compare_type
Definition res-a1.hpp:117
int max_level() const
Definition res-a1.cpp:1176
int compare_compares(res_pair *f, res_pair *g) const
Definition res-a1.cpp:500
int component_number
Definition res-a1.hpp:108
void skeleton_stats(const VECTOR(res_pair *)&reslevel)
Definition res-a1.cpp:1607
VECTOR(MonomialIdeal *) search_mi
int next_me_number
Definition res-a1.hpp:107
VECTOR(res_pair *) base_components
const Monoid * M
Definition res-a1.hpp:80
int lodegree
Definition res-a1.hpp:97
enum ComputationStatusCode pairs(int level, int deg)
Definition res-a1.cpp:997
int n_level
Definition res-a1.hpp:88
int low_degree() const
Definition res-a1.cpp:1177
void reduce_gen(resterm *&f) const
Definition res-a1.cpp:844
void skeleton_init(VECTOR(res_pair *)&reslevel)
Definition res-a1.cpp:1473
enum ComputationStatusCode gens(int deg)
Definition res-a1.cpp:964
M2_arrayint get_betti(int type) const
Definition res-a1.cpp:1179
res_pair * reduce_level_one(resterm *&f, resterm *&fsyz, resterm *&pivot)
Definition res-a1.cpp:795
const Matrix * generator_matrix
Definition res-a1.hpp:82
void sort_gens(res_degree *pairs)
Definition res-a1.cpp:470
res_pair * elem(int lev, int n) const
Definition res-a1.hpp:119
void multi_degree(const res_pair *q, monomial result) const
Definition res-a1.cpp:280
int length_limit
Definition res-a1.hpp:99
virtual ~res_comp()
Definition res-a1.cpp:122
stash * mi_stash
Definition res-a1.hpp:85
int compare_res_pairs(res_pair *f, res_pair *g) const
Definition res-a1.cpp:318
int max_degree
Definition res-a1.hpp:102
int complete_thru_degree() const
Definition res-a1.cpp:895
stash * res_pair_stash
Definition res-a1.hpp:84
void stats() const
Definition res-a1.cpp:1294
const FreeModule * get_free(int level)
Definition res-a1.hpp:210
int n_degree
Definition res-a1.hpp:89
res_poly * R
Definition res-a1.hpp:79
void resize(const Ring *new_ring)
int n_pairs(int lev, int d) const
Definition res-a1.cpp:1135
void skeleton_pairs(res_pair *&result, res_pair *p)
Definition res-a1.cpp:1496
res_comp(const Matrix *m, int LengthLimit, int strategy)
Definition res-a1.cpp:117
int find_ring_divisor(const_exponents exp, ring_elem &result) const
Definition res-a1.cpp:710
int sort_value(res_pair *p, const std::vector< int > sort_order) const
Definition res-a1.cpp:463
const Ring * K
Definition res-a1.hpp:81
int nleft
Definition res-a1.hpp:109
int nminimal
Definition res-a1.hpp:111
void remove_res_degree(res_degree *p)
Definition res-a1.cpp:147
VECTOR(res_level *) resn
void skeleton(int strategy)
Definition res-a1.cpp:1658
int npairs
Definition res-a1.hpp:110
const FreeModule * free_of(int i) const
Definition res-a1.cpp:1341
void remove_res_pair(res_pair *p)
Definition res-a1.cpp:137
res_pair * new_res_pair()
Definition res-a1.cpp:210
void sort_res_pairs(res_pair *&p) const
Definition res-a1.cpp:438
void new_pairs(res_pair *p)
Definition res-a1.cpp:606
Matrix * make(int i) const
Definition res-a1.cpp:1388
int n_minimal(int lev, int d) const
Definition res-a1.cpp:1154
M2_arrayint betti_minimal() const
Definition res-a1.cpp:1225
const Matrix * get_matrix(int level)
Definition res-a1.hpp:205
res_pair * merge_res_pairs(res_pair *f, res_pair *g) const
Definition res-a1.cpp:404
void text_out(const res_pair *p) const
Definition res-a1.cpp:1287
res_pair * reduce(resterm *&f, resterm *&fsyz, resterm *&pivot)
Definition res-a1.cpp:743
void set_compare_nums(int level, int deg)
Definition res-a1.cpp:569
void initialize(const Matrix *mat, int LengthLimit, int strategy)
Definition res-a1.cpp:14
res_degree * get_degree_set(int level, int d) const
Definition res-a1.cpp:200
void start_computation()
Definition res-a1.cpp:917
M2_arrayint betti_nmonoms() const
Definition res-a1.cpp:1226
const PolynomialRing * P
Definition res-a1.hpp:78
const FreeModule * minimal_free_of(int i) const
Definition res-a1.cpp:1363
void reduce_minimal(int x, resterm *&f, VECTOR(res_pair *)&elems) const
Definition res-a1.cpp:1410
void handle_pair(res_pair *p)
Definition res-a1.cpp:1075
int skeleton_maxdegree(const VECTOR(res_pair *)&reslevel)
Definition res-a1.cpp:1593
void insert_res_pair(int level, res_pair *p)
Definition res-a1.cpp:288
void handle_gen(res_pair *p)
Definition res-a1.cpp:1053
M2_arrayint betti_skeleton() const
Definition res-a1.cpp:1223
res_pair * merge_compares(res_pair *f, res_pair *g) const
Definition res-a1.cpp:511
int high_degree() const
Definition res-a1.cpp:1178
bool stop_conditions_ok()
Definition res-a1.cpp:879
size_t monom_size
Definition res-a1.hpp:115
One of the Resolution computations, based on Schreyer and Lascala.
Definition res-a1.hpp:76
res_pair * next_new_pair
Definition res-a1.hpp:27
int nminimal
Definition res-a1.hpp:34
int npairs
Definition res-a1.hpp:32
friend class res_comp
Definition res-a1.hpp:23
res_pair * next_gen
Definition res-a1.hpp:29
~res_degree()
Definition res-a1.hpp:48
int nleft
Definition res-a1.hpp:33
res_pair * first
Definition res-a1.hpp:25
res_pair * next_pair
Definition res-a1.hpp:28
int is_sorted
Definition res-a1.hpp:31
int npairs
Definition res-a1.hpp:62
int nleft
Definition res-a1.hpp:63
friend class res_comp
Definition res-a1.hpp:54
VECTOR(res_pair *) elems
int nminimal
Definition res-a1.hpp:64
res_pair * compare_num_list
Definition res-a1.hpp:61
res_level()
Definition res-a1.hpp:67
VECTOR(res_degree *) bin
Definition mem.hpp:78
ResolutionComputation — abstract base for every free-resolution algorithm in the engine.
ComputationStatusCode
Definition computation.h:53
#define Matrix
Definition factory.cpp:14
#define monomial
Definition gb-toric.cpp:11
int p
VALGRIND_MAKE_MEM_DEFINED & result(result)
Matrix — the engine's immutable homomorphism F -> G between free modules.
MonomialIdeal — exponent-vector-only representation of an ideal generated by monomials.
#define VECTOR(T)
Definition newdelete.hpp:78
volatile int x
PolynomialRing — abstract polynomial-ring base, the engine's most-reused class.
Engine-wide stylistic constants: LT / EQ / GT codes, INTSIZE, GEOHEAP_SIZE.