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

◆ remainder() [2/2]

void ReducedGB_Field_Local::remainder ( POLY & f,
bool use_denom,
ring_elem & denom )
virtual

Reimplemented from ReducedGB_Field.

Definition at line 492 of file reducedgb-field-local.cpp.

493{
494 if (M2_gbTrace >= 4) {
495 buffer o;
496 text_out(o);
497 emit(o.str());
498 }
499 if (f.f == nullptr) return;
500 T1 = MonomialTable::make(R->n_vars());
501 gbvector head;
502 gbvector *frem = &head;
503 frem->next = nullptr;
504 POLY h = f;
505 exponents_t h_exp = R->exponents_make();
506 int h_alpha, g_alpha;
507 int h_deg = wt->gbvector_weight(f.f);
508 while (!R->gbvector_is_zero(h.f))
509 {
510 if (M2_gbTrace == 3) emit_wrapped(".");
511 POLY g;
512 R->gbvector_get_lead_exponents(F, h.f, h_exp);
513 int h_comp = h.f->comp;
514
515 if (M2_gbTrace >= 4)
516 {
517 buffer o;
518 o << "\nreducing ";
519 R->gbvector_text_out(o, F, h.f);
520 emit(o.str());
521 }
522
523 if (find_good_divisor(h_exp,
524 h_comp,
525 h_deg,
526 h_alpha,
527 g,
528 g_alpha)) // sets these three values
529 {
530 if (M2_gbTrace >= 4)
531 {
532 buffer o;
533 o << " h_alpha " << h_alpha << " g_alpha "
534 << g_alpha; // << " reducing using ";
535 // R->gbvector_text_out(o,F,g.f);
536 // o << newline;
537 emit(o.str());
538 }
539 if (g_alpha > h_alpha)
540 {
541 if (head.next != nullptr)
542 {
543 // In this case, we can't reduce the tail without
544 // risking an infinite loop. So we declare ourselves done
545 // Attach the rest of h.f to frem
546 frem->next = h.f;
547 break;
548 }
549 // place h into T1, and store its (value,deg,alpha) values.
550 // store_in_table copies h
551 store_in_table(h, h_exp, h_comp, h_alpha);
552 if (M2_gbTrace == 3) emit_wrapped("x");
553 if (M2_gbTrace == 4) emit("\nstored result\n");
554 h_deg += g_alpha - h_alpha;
555 h_exp = R->exponents_make();
556 }
557 R->gbvector_reduce_lead_term(
558 F, Fsyz, head.next, h.f, h.fsyz, g.f, g.fsyz, use_denom, denom);
559 }
560 else
561 {
562 frem->next = h.f;
563 frem = frem->next;
564 h.f = h.f->next;
565 frem->next = nullptr;
566 }
567 }
568
569 f.f = head.next;
570 f.fsyz = h.fsyz;
571 R->exponents_delete(h_exp);
572 reset_table();
573}
exponents::Exponents exponents_t
static MonomialTable * make(int nvars)
Definition montable.cpp:61
bool find_good_divisor(exponents_t h_exp, int h_comp, int h_deg, int &h_alpha, POLY &result_g, int &result_g_alpha)
void store_in_table(const POLY &h, exponents_t h_exp, int h_comp, int h_alpha)
virtual void text_out(buffer &o) const
const FreeModule * Fsyz
Definition reducedgb.hpp:67
GBRing * R
Definition reducedgb.hpp:64
const FreeModule * F
Definition reducedgb.hpp:66
char * str()
Definition buffer.hpp:72
int M2_gbTrace
Definition m2-types.cpp:52
#define POLY(q)
Definition poly.cpp:23
gbvector * fsyz
Definition gbring.hpp:99
gbvector * f
Definition gbring.hpp:98
gbvector * next
Definition gbring.hpp:80
int comp
Definition gbring.hpp:82
void emit_wrapped(const char *s)
Definition text-io.cpp:27
void emit(const char *s)
Definition text-io.cpp:41

References gbvector::comp, emit(), emit_wrapped(), ReducedGB::F, POLY::f, find_good_divisor(), ReducedGB::Fsyz, POLY::fsyz, M2_gbTrace, MonomialTable::make(), gbvector::next, POLY, ReducedGB::R, reset_table(), store_in_table(), buffer::str(), T1, ReducedGB::text_out(), and wt.

Referenced by minimalize().