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

◆ minimalize_pairs_ZZ()

void gbA::minimalize_pairs_ZZ ( spairs & new_set)
private

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

857{
858 // Prune down the set of spairs to a 'minimal' set. For each one, we
859 // need to add in a "gcd" combination spair as well.
860
861 VECTOR(mpz_srcptr) coeffs;
862 VECTOR(mpz_srcptr) coeffs2;
863 VECTOR(exponents_t) exps;
864 VECTOR(int) comps;
865 VECTOR(int) positions;
866
867 coeffs.reserve(gb.size());
868 coeffs2.reserve(gb.size());
869 exps.reserve(gb.size());
870 comps.reserve(gb.size());
871
872 for (VECTOR(spair *)::iterator i = new_set.begin(); i != new_set.end(); i++)
873 {
874 spair *a = *i;
875 exps.push_back(a->lcm);
876 comps.push_back(1); /* This is not needed here, as all of these
877 have the same component */
878 /* Now get the coefficient */
879 /* This is the lcm divided by the lead coeff, but it depends on the kind
880 * of spair */
881 if (a->type == SPAIR::SPAIR_SKEW)
882 {
883 coeffs.push_back(globalZZ->one().get_mpz());
884 coeffs2.push_back(nullptr); // will never be referred to below
885 }
886 else
887 {
888 /* */
889 gbvector *f1 = gb[a->x.pair.i]->g.f;
890 gbvector *f2 = gb[a->x.pair.j]->g.f;
891 ring_elem u, v;
892 globalZZ->syzygy(f1->coeff, f2->coeff, u, v);
893 coeffs.push_back(u.get_mpz());
894 coeffs2.push_back(v.get_mpz());
895
896 if (mpz_cmpabs_ui(u.get_mpz(), 1) && mpz_cmpabs_ui(v.get_mpz(), 1))
897 {
898 spair *p2 = spair_make_gcd_ZZ(a->x.pair.i, a->x.pair.j);
899 if (M2_gbTrace >= 4)
900 {
901 buffer o;
902 o << " creating ";
903 spair_text_out(o, p2);
904 emit_line(o.str());
905 }
907 }
908 }
909 }
910
911 if (_strategy == 0)
913 _nvars, coeffs, exps, comps, positions);
914 else
916 _nvars, coeffs, exps, comps, positions, true);
917
918 for (VECTOR(int)::iterator i = positions.begin(); i != positions.end(); i++)
919 {
920 // Insert this spair, and also the corresponding gcd one.
921 spair *p = new_set[*i];
922 if (M2_gbTrace >= 4)
923 {
924 buffer o;
925 o << " creating ";
926 spair_text_out(o, p);
927 emit_line(o.str());
928 }
930#if 0
931 mpz_ptr u = coeffs[*i];
932 mpz_ptr v = coeffs2[*i];
933 if (p->type != SPAIR::SPAIR_SKEW && mpz_cmpabs_ui(u,1) && mpz_cmpabs_ui(v,1))
934 {
935 spair *p2 = spair_make_gcd_ZZ(p->x.pair.i, p->x.pair.j);
936 if (M2_gbTrace >= 4)
937 {
938 buffer o;
939 spair_text_out(o, p2);
940 emit_line(o.str());
941 }
943 }
944#endif
945 }
946}
exponents::Exponents exponents_t
static void find_weak_generators(int nvars, const VECTOR(mpz_srcptr) &coeffs, const VECTOR(exponents_t) &exps, const VECTOR(int) &comps, VECTOR(int) &result_positions, bool use_stable_sort=true)
ring_elem one() const
Definition ring.hpp:357
virtual void syzygy(const ring_elem a, const ring_elem b, ring_elem &x, ring_elem &y) const
Definition ZZ.cpp:386
char * str()
Definition buffer.hpp:72
void spair_text_out(buffer &o, spair *p)
int _strategy
int _nvars
void spair_set_insert(spair *p)
spair * spair_make_gcd_ZZ(int i, int j)
@ SPAIR_SKEW
void gb(IntermediateBasis &F, int n)
RingZZ * globalZZ
Definition relem.cpp:13
int p
int M2_gbTrace
Definition m2-types.cpp:52
#define VECTOR(T)
Definition newdelete.hpp:78
ring_elem coeff
Definition gbring.hpp:81
int j
Definition f4-types.hpp:129
monomial_word * lcm
Definition f4-types.hpp:130
SPairType type
Definition f4-types.hpp:126
int i
Definition f4-types.hpp:128
void emit_line(const char *s)
Definition text-io.cpp:47
mpz_srcptr get_mpz() const
Definition ringelem.hpp:127

References _nvars, _strategy, gbvector::coeff, emit_line(), MonomialTableZZ::find_weak_generators(), gb(), ring_elem::get_mpz(), globalZZ, gbA::spair::lcm, M2_gbTrace, p, gbA::spair::pair, spair_make_gcd_ZZ(), spair_set_insert(), SPAIR_SKEW, spair_text_out(), buffer::str(), gbA::spair::type, VECTOR, and gbA::spair::x.

Referenced by minimalize_pairs().