Skip to content

Commit

Permalink
implemented Mike's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Feb 9, 2023
1 parent ed2988e commit e42fdc1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions M2/Macaulay2/e/gbweight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "gbring.hpp"
#include "polyring.hpp"


GBWeight::GBWeight(const FreeModule *F, M2_arrayint wts0) : F_(F)
{
// If wts has length 0 or is NULL:
Expand Down Expand Up @@ -54,12 +55,11 @@ GBWeight::GBWeight(const FreeModule *F, M2_arrayint wts0) : F_(F)
Fdegs_ = 0;
}

int GBWeight::exponents_weight(const int *e, int comp) const
int GBWeight::exponents_weight(const_exponents e, int comp) const
{
long sum = 0;
for (int i = 0; i < nvars_; i++) sum += e[i] * wts_->array[i];
int sum = exponents::weight(nvars_, e, wts_);
if (use_component_degrees_ && comp > 0) sum += Fdegs_[comp];
return static_cast<int>(sum);
return sum;
}

int GBWeight::gbvector_term_weight(const gbvector *f) const
Expand Down Expand Up @@ -96,7 +96,7 @@ int GBWeight::gbvector_weight(const gbvector *f) const
return gbvector_weight(f, not_used);
}

int GBWeight::monomial_weight(const int *monom, int comp) const
int GBWeight::monomial_weight(const_monomial monom, int comp) const
{
exponents_t EXP = ALLOCATE_EXPONENTS(exp_size);
R_->get_flattened_monoid()->to_expvector(monom, EXP);
Expand Down
12 changes: 8 additions & 4 deletions M2/Macaulay2/e/gbweight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
#ifndef _gbweight_hpp_
#define _gbweight_hpp_

#include "ringelem.hpp" // TODO: needed for M2_arrayint
#include "newdelete.hpp"
#include "engine-includes.hpp" // for M2_arrayint

#include "ExponentVector.hpp" // for const_exponents
#include "monoid.hpp" // for const_monomial
#include "newdelete.hpp" // for our_new_delete

class FreeModule;
class GBRing;
class gbvector;

Expand All @@ -32,15 +36,15 @@ class GBWeight : public our_new_delete
// or, if the component is 0, then it is in the ring, not in the
// free module F_

int exponents_weight(const int *e, int comp) const;
int exponents_weight(const_exponents e, int comp) const;

int gbvector_term_weight(const gbvector *f) const;

int gbvector_weight(const gbvector *f) const;

int gbvector_weight(const gbvector *f, int &lead_term_weight) const;

int monomial_weight(const int *monom, int comp) const;
int monomial_weight(const_monomial m, int comp) const;
};

#endif
Expand Down
5 changes: 2 additions & 3 deletions M2/Macaulay2/e/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,6 @@ Matrix /* or null */ *Matrix::koszul_monomials(int nskew,
for (int j = 0; j < nskew; j++) skew_list[j] = j;
SkewMultiplication skew(nvars, nskew, skew_list);
int ncols = c->n_cols();
const_monomial a;

exponents_t aexp = newarray_atomic(int, nvars);
exponents_t bexp = newarray_atomic(int, nvars);
Expand All @@ -1160,14 +1159,14 @@ Matrix /* or null */ *Matrix::koszul_monomials(int nskew,
for (int i = 0; i < ncols; i++)
{
if (c->elem(i) == nullptr) continue;
a = P->lead_flat_monomial(c->elem(i)->coeff);
const_monomial a = P->lead_flat_monomial(c->elem(i)->coeff);
M->to_expvector(a, aexp);
divisors.clear();
A->find_all_divisors(aexp, divisors);
for (int j = 0; j < divisors.size(); j++)
{
int rownum = divisors[j]->basis_elem();
const int *b = P->lead_flat_monomial(r->elem(rownum)->coeff);
const_monomial b = P->lead_flat_monomial(r->elem(rownum)->coeff);
M->to_expvector(b, bexp);
exponents::divide(nvars, aexp, bexp, result_exp);
int sign = skew.mult_sign(result_exp, bexp);
Expand Down

0 comments on commit e42fdc1

Please sign in to comment.