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

◆ remainder() [1/2]

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

Reimplemented from ReducedGB_Field.

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

578{
579 if (f == nullptr) return;
580
581 T1 = MonomialTable::make(R->n_vars());
582 gbvector *zero = nullptr;
583 gbvector head;
584 gbvector *frem = &head;
585 frem->next = nullptr;
586 POLY h;
587 h.f = f;
588 h.fsyz = nullptr;
589 exponents_t h_exp = R->exponents_make();
590 int h_alpha, g_alpha;
591 int h_deg = wt->gbvector_weight(f);
592 while (!R->gbvector_is_zero(h.f))
593 {
594 if (M2_gbTrace == 3) emit_wrapped(".");
595 POLY g;
596 R->gbvector_get_lead_exponents(F, h.f, h_exp);
597 int h_comp = h.f->comp;
598
599 if (M2_gbTrace >= 4)
600 {
601 buffer o;
602 o << "\nreducing ";
603 R->gbvector_text_out(o, F, h.f);
604 emit(o.str());
605 }
606
607 if (find_good_divisor(h_exp,
608 h_comp,
609 h_deg,
610 h_alpha,
611 g,
612 g_alpha)) // sets these three values
613 {
614 if (M2_gbTrace >= 4)
615 {
616 buffer o;
617 o << " h_alpha " << h_alpha << " g_alpha "
618 << g_alpha; // << " reducing using ";
619 // R->gbvector_text_out(o,F,g.f);
620 // o << newline;
621 emit(o.str());
622 }
623 if (g_alpha > h_alpha)
624 {
625 if (head.next != nullptr)
626 {
627 // In this case, we can't reduce the tail without
628 // risking an infinite loop. So we declare ourselves done
629 // Attach the rest of h.f to frem
630 frem->next = h.f;
631 break;
632 }
633 // place h into T1, and store its (value,deg,alpha) values.
634 store_in_table(h, h_exp, h_comp, h_alpha);
635 if (M2_gbTrace == 3) emit_wrapped("x");
636 if (M2_gbTrace == 4) emit("\nstored result\n");
637 h_deg += g_alpha - h_alpha;
638 h_exp = R->exponents_make();
639 }
640 R->gbvector_reduce_lead_term(
641 F, Fsyz, head.next, h.f, zero, g.f, zero, use_denom, denom);
642 }
643 else
644 {
645 frem->next = h.f;
646 frem = frem->next;
647 h.f = h.f->next;
648 frem->next = nullptr;
649 }
650 }
651
652 f = head.next;
653 R->exponents_delete(h_exp);
654 reset_table();
655}
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)
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 zero
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, wt, and zero.