Macaulay2 Engine
Loading...
Searching...
No Matches

◆ setup()

void gbres_comp::setup ( const Matrix * m,
int length,
int origsyz,
int strategy )
private

Definition at line 79 of file res-a2.cpp.

80{
81 int i;
83 if (originalR == nullptr) assert(0);
84 GR = originalR->get_gb_ring();
85 mi_stash = new stash("res mi nodes", sizeof(Nmi_node));
86
87 FreeModule *Fsyz = originalR->make_Schreyer_FreeModule();
88 if (length <= 0)
89 {
90 ERROR("resolution length must be at least 1");
91 length = 1;
92 }
93
94 // If origsyz, and length>1, create Fsyz as a Schreyer free
95 // if origsyz is smaller, truncate this module...
96
97 if (length > 1 && origsyz > 0)
98 {
99 if (origsyz > m->n_cols()) origsyz = m->n_cols();
100 monomial one = originalR->getMonoid()->make_one();
101 const int *mon;
102 for (i = 0; i < origsyz; i++)
103 {
104 if ((*m)[i] == nullptr)
105 mon = one;
106 else
107 {
108 Nterm *t = (*m)[i]->coeff;
109 mon = t->monom;
110 }
111 Fsyz->append_schreyer(m->cols()->degree(i), mon, i);
112 }
113 originalR->getMonoid()->remove(one);
114 }
115
118
119 n_nodes = length + 1;
121
122 nodes[0] = new gb_emitter(m);
123 nodes[1] =
124 new gb2_comp(Fsyz, mi_stash, nodes[0], lo_degree, origsyz, 1, strategy);
125 nodes[0]->set_output(nodes[1]);
126 if (n_nodes == 2)
127 {
128 // Don't compute syzygies at all.
129 nodes[1]->set_output(nullptr);
130 }
131 else if (n_nodes >= 3)
132 {
133 // Compute a resolution to length 'length', with last being
134 // a gb node.
135 int deg = lo_degree + 1;
136 if (origsyz > 0) deg--;
137 for (i = 2; i < n_nodes - 1; i++)
138 {
139 FreeModule *F = originalR->make_Schreyer_FreeModule();
140 nodes[i] =
141 new gb2_comp(F, mi_stash, nodes[i - 1], deg++, -1, i, strategy);
142 nodes[i - 1]->set_output(nodes[i]);
143 }
144 FreeModule *F = originalR->make_Schreyer_FreeModule();
145 nodes[n_nodes - 1] = new gb2_comp(
146 F, mi_stash, nodes[n_nodes - 2], deg++, 0, n_nodes - 1, strategy);
147 nodes[n_nodes - 1]->set_output(nullptr);
148 }
149 strategy_flags = strategy;
150}
const_monomial degree(int i) const
Definition freemod.hpp:104
int lowest_primary_degree() const
Definition freemod.cpp:447
void append_schreyer(const_monomial d, const_monomial base_monom, int compare_num)
Definition freemod.cpp:137
const Ring * get_ring() const
Definition matrix.hpp:134
int n_cols() const
Definition matrix.hpp:147
const FreeModule * cols() const
Definition matrix.hpp:145
virtual const PolynomialRing * cast_to_PolynomialRing() const
Definition ring.hpp:243
int n_nodes
Definition res-a2.hpp:253
int lo_degree
Definition res-a2.hpp:256
gb_node ** nodes
Definition res-a2.hpp:254
stash * mi_stash
Definition res-a2.hpp:251
int strategy_flags
Definition res-a2.hpp:258
const PolynomialRing * originalR
Definition res-a2.hpp:250
GBRing * GR
Definition res-a2.hpp:252
int last_completed_degree
Definition res-a2.hpp:257
#define monomial
Definition gb-toric.cpp:11
const int ERROR
Definition m2-mem.cpp:55
#define newarray(T, len)
Definition newdelete.hpp:82
gb_node * gb_node_ptr
Definition res-a2.cpp:77
int monom[1]
Definition ringelem.hpp:160

References FreeModule::append_schreyer(), Ring::cast_to_PolynomialRing(), Nterm::coeff, Matrix::cols(), FreeModule::degree(), ERROR, Matrix::get_ring(), GR, last_completed_degree, lo_degree, FreeModule::lowest_primary_degree(), Matrix, mi_stash, Nterm::monom, monomial, Matrix::n_cols(), n_nodes, newarray, nodes, originalR, and strategy_flags.

Referenced by gbres_comp(), and gbres_comp().