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

◆ tail_remainder_ZZ()

void gbA::tail_remainder_ZZ ( POLY & f,
int degf )
private

Definition at line 1921 of file gb-default.cpp.

1922{
1923 gbvector head;
1924 gbvector *frem = &head;
1925 int count = 0;
1926 POLY h = f;
1927
1929
1930 frem->next = h.f;
1931 frem = frem->next;
1932 h.f = h.f->next;
1933 frem->next = nullptr;
1934
1935 while (!R->gbvector_is_zero(h.f))
1936 {
1937 int gap;
1938 R->gbvector_get_lead_exponents(_F, h.f, EXP);
1939 int x = h.f->comp;
1941 h.f->coeff.get_mpz(), EXP, x, degf, gap);
1942 // replaced gap, g.
1943 if (w < 0 || gap > 0)
1944 {
1945 frem->next = h.f;
1946 frem = frem->next;
1947 h.f = h.f->next;
1948 frem->next = nullptr;
1949 }
1950 else
1951 {
1952 POLY g = gb[w]->g;
1953 if (!R->gbvector_reduce_lead_term_ZZ(
1954 _F, _Fsyz, h.f, h.fsyz, g.f, g.fsyz))
1955 {
1956 // This term is still there, so we must move it to result.
1957 frem->next = h.f;
1958 frem = frem->next;
1959 h.f = h.f->next;
1960 frem->next = nullptr;
1961 }
1962 count++;
1963 // stats_ntail++;
1964 if (M2_gbTrace == 15)
1965 {
1966 buffer o;
1967 o << " tail red by g" << w;
1968 o << ", yielding ";
1969 R->gbvector_text_out(o, _F, h.f, 3);
1970 emit_line(o.str());
1971 }
1972 }
1973 }
1974 h.f = head.next;
1975 // Negate these if needed
1976 if (h.f != nullptr && mpz_sgn(h.f->coeff.get_mpz()) < 0)
1977 {
1978 R->gbvector_mult_by_coeff_to(h.f, globalZZ->minus_one());
1979 R->gbvector_mult_by_coeff_to(h.fsyz, globalZZ->minus_one());
1980 }
1981 f.f = h.f;
1982 f.fsyz = h.fsyz;
1983 if ((M2_gbTrace & PRINT_SPAIR_TRACKING) != 0)
1984 {
1985 buffer o;
1986 o << "number of reduction steps was " << count;
1987 emit_line(o.str());
1988 }
1989 else if (M2_gbTrace >= 4 && M2_gbTrace != 15)
1990 {
1991 buffer o;
1992 o << "," << count;
1993 emit_wrapped(o.str());
1994 }
1995}
exponents::Exponents exponents_t
ring_elem minus_one() const
Definition ring.hpp:358
char * str()
Definition buffer.hpp:72
GBRing * R
int find_good_monomial_divisor_ZZ(mpz_srcptr c, exponents_t e, int x, int degf, int &result_gap)
const FreeModule * _F
const FreeModule * _Fsyz
size_t exp_size
@ PRINT_SPAIR_TRACKING
void gb(IntermediateBasis &F, int n)
RingZZ * globalZZ
Definition relem.cpp:13
int M2_gbTrace
Definition m2-types.cpp:52
#define ALLOCATE_EXPONENTS(byte_len)
Definition monoid.hpp:62
volatile int x
#define POLY(q)
Definition poly.cpp:23
gbvector * fsyz
Definition gbring.hpp:99
gbvector * f
Definition gbring.hpp:98
ring_elem coeff
Definition gbring.hpp:81
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_line(const char *s)
Definition text-io.cpp:47
mpz_srcptr get_mpz() const
Definition ringelem.hpp:127

References _F, _Fsyz, ALLOCATE_EXPONENTS, gbvector::coeff, gbvector::comp, emit_line(), emit_wrapped(), exp_size, POLY::f, find_good_monomial_divisor_ZZ(), POLY::fsyz, gb(), ring_elem::get_mpz(), globalZZ, M2_gbTrace, gbvector::next, POLY, PRINT_SPAIR_TRACKING, R, buffer::str(), and x.

Referenced by replace_gb_element_ZZ().