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

◆ reduce2()

res2_pair * res2_comp::reduce2 ( res2term *& f,
res2term *& fsyz,
res2term *& pivot,
res2_pair * p )
private

Definition at line 1200 of file res-a0.cpp.

1209{
1210 // 'lastterm' is used to append the next monomial to fsyz->syz
1213
1214 res2term *lastterm = (fsyz->next == nullptr ? fsyz : fsyz->next);
1215 res2term head;
1216 res2term *red = &head;
1217 res2_pair *result = nullptr;
1218 res2_pair *q;
1219 ring_elem rg;
1220
1221 int count = 0;
1222 if (M2_gbTrace >= 4) emit_wrapped(",");
1223
1224 while (f != nullptr)
1225 {
1226 M->divide(f->monom, f->comp->syz->monom, REDUCE_mon);
1227 M->to_expvector(REDUCE_mon, REDUCE_exp);
1228 if (find_ring_divisor(REDUCE_exp, rg))
1229 {
1230 // Subtract off f, leave fsyz alone
1231 Nterm *r = rg;
1232 M->divide(f->monom, r->monom, REDUCE_mon);
1233 R->ring_subtract_multiple_to(f, f->coeff, REDUCE_mon, f->comp, rg);
1235 count++;
1236 }
1237 else if (find_divisor(f->comp->mi, REDUCE_exp, q))
1238 {
1240 {
1241 if (result == nullptr || auto_reduce >= 2)
1242 {
1243 lastterm->next =
1244 R->new_term(K->negate(f->coeff), f->monom, q);
1245 lastterm = lastterm->next;
1246 if (result == nullptr)
1247 {
1248 // Only do this for the first non-computed pair
1249 pivot = lastterm;
1250 result = q;
1251 }
1252 else if (auto_reduce == 2)
1253 {
1254 // Keep track of this element for later reduction
1255 // Store it with q. Now for a bit of a hack:
1256 // We store it in the 'pivot_term' field, since
1257 // it cannot have been set yet, and since we don't want
1258 // to waste space.
1259 auto_reduce_node *au = new auto_reduce_node;
1260 au->next =
1261 reinterpret_cast<auto_reduce_node *>(q->pivot_term);
1262 au->p = pivot->comp;
1263 au->pivot = lastterm;
1264 q->pivot_term = reinterpret_cast<res2term *>(au);
1265 }
1266 if (auto_reduce == 0)
1267 {
1268 // Time to leave: 'red' has nothing in it
1269 // with this option, and 'f' is set correctly.
1270 return result;
1271 }
1272 }
1273 red->next = f;
1274 red = red->next;
1275 f = f->next;
1276 continue;
1277 }
1278 else
1279 {
1280 lastterm->next = R->new_term(K->negate(f->coeff), f->monom, q);
1281 lastterm = lastterm->next;
1282 M->divide(f->monom, q->syz->monom, REDUCE_mon);
1283 R->subtract_multiple_to(f, f->coeff, REDUCE_mon, q->syz);
1285 count++;
1286 }
1287 }
1288 else
1289 {
1290 red->next = f;
1291 red = red->next;
1292 f = f->next;
1293 }
1294 }
1295 red->next = nullptr;
1296 f = head.next;
1297 if (M2_gbTrace >= 4)
1298 {
1299 buffer o;
1300 o << count;
1301 emit_wrapped(o.str());
1302 }
1303 return result;
1304}
exponents::Exponents exponents_t
char * str()
Definition buffer.hpp:72
size_t exp_size
Definition res-a0.hpp:192
int total_reduce_count
Definition res-a0.hpp:184
size_t monom_size
Definition res-a0.hpp:193
res2_poly * R
Definition res-a0.hpp:123
const Monoid * M
Definition res-a0.hpp:124
int auto_reduce
Definition res-a0.hpp:178
int find_ring_divisor(const int *exp, ring_elem &result) const
Definition res-a0.cpp:1048
int find_divisor(const MonomialIdeal *mi, const int *exp, res2_pair *&result)
Definition res-a0.cpp:1060
const Ring * K
Definition res-a0.hpp:125
#define monomial
Definition gb-toric.cpp:11
VALGRIND_MAKE_MEM_DEFINED & result(result)
int M2_gbTrace
Definition m2-types.cpp:52
#define ALLOCATE_EXPONENTS(byte_len)
Definition monoid.hpp:62
#define ALLOCATE_MONOMIAL(byte_len)
Definition monoid.hpp:65
@ SYZ2_MAYBE_MINIMAL
@ SYZ2_S_PAIR
int monom[1]
Definition ringelem.hpp:160
res2term * pivot
Definition res-a0.hpp:92
auto_reduce_node * next
Definition res-a0.hpp:91
res2_pair * p
Definition res-a0.hpp:93
MonomialIdeal * mi
res2term * syz
res2term * pivot_term
unsigned char syz_type
res2term * next
res2_pair * comp
ring_elem coeff
int monom[1]
void emit_wrapped(const char *s)
Definition text-io.cpp:27

References ALLOCATE_EXPONENTS, ALLOCATE_MONOMIAL, auto_reduce, res2term::coeff, res2term::comp, emit_wrapped(), exp_size, find_divisor(), find_ring_divisor(), K, M, M2_gbTrace, res2_pair::mi, Nterm::monom, res2term::monom, monom_size, monomial, auto_reduce_node::next, res2term::next, auto_reduce_node::p, auto_reduce_node::pivot, res2_pair::pivot_term, R, result(), buffer::str(), res2_pair::syz, SYZ2_MAYBE_MINIMAL, SYZ2_S_PAIR, res2_pair::syz_type, and total_reduce_count.

Referenced by handle_pair().