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

◆ getMonomialReversed()

void FreeMonoid::getMonomialReversed ( Monom monom,
std::vector< int > & result ) const

Definition at line 233 of file FreeMonoid.cpp.

239{
240 auto start = result.size();
241 result.push_back(0);
242 auto word_length = wordLength(m);
243 auto word_ptr = m + mNumWeights + 1;
244 for (auto j = word_length-1; j >= 0; --j)
245 {
246 int curvar = word_ptr[j];
247 int curvarPower = 0;
248 result.push_back(curvar);
249 while ((j >= 0) && (word_ptr[j] == curvar))
250 {
251 --j;
252 curvarPower++;
253 }
254 result.push_back(curvarPower);
255 // back j up one since we went too far looking ahead.
256 j++;
257 }
258 result[start] = static_cast<int>(result.size() - start);
259}
const int mNumWeights
int wordLength(const Monom &m) const
VALGRIND_MAKE_MEM_DEFINED & result(result)

References mNumWeights, result(), and wordLength().

Referenced by FreeAlgebra::eval(), and M2FreeAlgebra::list_form().