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

◆ insert_gb_element()

void F4GB::insert_gb_element ( row_elem & r)
private

Definition at line 899 of file f4.cpp.

900{
901 // Insert row as gb element.
902 // Actions to do:
903 // translate row to a gbelem + poly
904 // set degrees as needed
905 // insert the monomial into the lookup table
906 // find new pairs associated to this new element
907
908 int nslots = mMonomialInfo->max_monomial_size();
909 int nlongs = r.len * nslots;
910
911 gbelem *result = new gbelem;
912 result->f.len = r.len;
913
914 // If the coeff array is null, then that means the coeffs come from the
915 // original array
916 // Here we copy it over.
917
918 // const ElementArray& v = (not r.coeffs.isNull() ? r.coeffs : mVectorArithmetic->copyElementArray(get_coeffs_array(r)));
919 // result->f.coeffs.swap(v);
920 if (r.coeffs.isNull())
921 {
922 // this means the actual coeff vector is coming from a GB element. Copy it into result->f.coeffs
923 ElementArray v { mVectorArithmetic->copyElementArray(get_coeffs_array(r)) };
924 result->f.coeffs.swap(v);
925 }
926 else
927 {
928 result->f.coeffs.swap(r.coeffs);
929 }
930
931 //result->f.monoms = Mem->allocate_monomial_array(nlongs);
932 result->f.monoms = new monomial_word[nlongs];
933
934 monomial_word *nextmonom = result->f.monoms;
935 for (int i = 0; i < r.len; i++)
936 {
937 mMonomialInfo->copy(mat->columns[r.comps[i]].monom, nextmonom);
938 nextmonom += nslots;
939 }
940 // Mem->components.deallocate(r.comps);
941 delete [] r.comps;
942 r.comps = nullptr;
943 r.len = 0;
944 result->deg = this_degree;
945 result->alpha = static_cast<int>(mMonomialInfo->last_exponent(result->f.monoms));
946 result->minlevel = ELEM_MIN_GB; // MES: How do
947 // we distinguish between ELEM_MIN_GB, ELEM_POSSIBLE_MINGEN?
948
949 int which = INTSIZE(mGroebnerBasis);
950 mGroebnerBasis.push_back(result);
951
952 if (hilbert)
953 {
954 int x;
955 //int *exp = newarray_atomic(int, M->n_vars());
956 int *exp = new int[mMonomialInfo->n_vars()];
957 mMonomialInfo->to_intstar_vector(result->f.monoms, exp, x);
958 hilbert->addMonomial(exp, x + 1);
959 delete [] exp;
960 //freemem(exp);
961 }
962 // now insert the lead monomial into the lookup table
963 //varpower_monomial vp = newarray_atomic(varpower_word, 2 * M->n_vars() + 1);
964 varpower_monomial vp = new varpower_word[2 * mMonomialInfo->n_vars() + 1];
965 mMonomialInfo->to_varpower_monomial(result->f.monoms, vp);
966 mLookupTable.insert_minimal_vp(mMonomialInfo->get_component(result->f.monoms), vp, which);
967 delete [] vp;
968 //freemem(vp);
969 // now go forth and find those new pairs
970 mtbb::tick_count t0 = mtbb::tick_count::now();
971 mSPairSet.find_new_pairs(is_ideal);
972 mtbb::tick_count t1 = mtbb::tick_count::now();
973 mNewSPairTime += (t1-t0).seconds();
974}
bool isNull() const
const ElementArray & get_coeffs_array(row_elem &r)
Definition f4.cpp:591
double mNewSPairTime
Definition f4.hpp:200
coefficient_matrix * mat
Definition f4.hpp:186
F4SPairSet mSPairSet
Definition f4.hpp:249
HilbertController * hilbert
Definition f4.hpp:175
const MonomialInfo * mMonomialInfo
Definition f4.hpp:157
int this_degree
Definition f4.hpp:171
MonomialLookupTable mLookupTable
Definition f4.hpp:182
const VectorArithmetic * mVectorArithmetic
Definition f4.hpp:156
bool is_ideal
Definition f4.hpp:172
gb_array mGroebnerBasis
Definition f4.hpp:181
@ ELEM_MIN_GB
Definition f4-types.hpp:76
VALGRIND_MAKE_MEM_DEFINED & result(result)
long monomial_word
Definition moninfo.hpp:77
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
volatile int x
int * comps
Definition f4-types.hpp:163
ElementArray coeffs
Definition f4-types.hpp:162
#define INTSIZE(a)
Definition style.hpp:37
double seconds(DurationType time_diff)
Definition timing.hpp:59
varpower_word * varpower_monomial
varpower_monomials::Exponent varpower_word

References row_elem::coeffs, row_elem::comps, ELEM_MIN_GB, get_coeffs_array(), hilbert, INTSIZE, is_ideal, ElementArray::isNull(), row_elem::len, mat, mGroebnerBasis, mLookupTable, mMonomialInfo, mNewSPairTime, mSPairSet, mVectorArithmetic, result(), seconds(), this_degree, and x.

Referenced by new_GB_elements().