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

◆ setWeights()

void FreeMonoid::setWeights ( Monom & m) const
private

Definition at line 314 of file FreeMonoid.cpp.

315{
316 // since Monoms are wrappers to const ints, it seems we need
317 // this line so we can set the weights, but I'm not 100% sure
318 auto monom = const_cast<int*>(m.begin());
319
320 int word_len = wordLength(m);
321 for (int j = 1; j <= mNumWeights; ++j)
322 monom[j] = 0;
323 // eventually replace both for loops with:
324 // word = Word(m)
325 //for (int k = 0; k < mNumWeights; ++k)
326 // monom[k+1] = wordWeight(word,iterator to beginning of kth weight)
327 for (int j = 0; j < word_len; ++j)
328 {
329 for (int k = 0; k < mNumWeights; ++k)
330 {
331 monom[k+1] += weightOfVar(m[mNumWeights+1+j],k);
332 }
333 }
334}
const int mNumWeights
int weightOfVar(int v, int wt) const
int wordLength(const Monom &m) const
const int * begin() const

References Monom::begin(), mNumWeights, weightOfVar(), and wordLength().

Referenced by fromMonomial(), monomInsertFromWord(), wordProductAsMonom(), wordProductAsMonom(), and wordProductAsMonom().