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

◆ divide()

bool ResMonoidSparse::divide ( res_const_packed_monomial m,
res_const_packed_monomial n,
res_packed_monomial result ) const
inline

Definition at line 388 of file res-moninfo-sparse.hpp.

391 {
392 // computes m/n, or tries to. If n divides m, then return true and set
393 // 'result' to m/n
394 // otherwise return false. In the latter case, it is possible that result
395 // will have been written into partially,
396 // but the result is not a well-formed monomial.
398 if (*m < *n) return false;
399 const int* vm = m + mFirstVar;
400 const int* vn = n + mFirstVar;
401 const int* vend = n + *n;
402 int* vresult = result + mFirstVar;
403 for (; vn != vend; ++vn)
404 {
405 if (*vn > *vm) return false;
406 if (*vn == *vm) ++vm;
407 *vresult++ = *vm++;
408 }
409 for (int i = 1; i < mFirstVar; ++i) result[i] = m[i] - n[i];
410 result[0] = m[0] - n[0] + mFirstVar;
411 return true;
412 }
unsigned long ncalls_divide
VALGRIND_MAKE_MEM_DEFINED & result(result)

References mFirstVar, ncalls_divide, and result().