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

◆ weight() [1/2]

template<class E, bool OC>
Exponent ExponentVector< E, OC >::weight ( int nvars,
ConstExponents a,
const std::vector< Exponent > & wts )
inlinestatic

Definition at line 234 of file ExponentVector.hpp.

237 {
238 // TODO: use std::inner_product?
239 Exponent top = wts.size();
240 if (nvars < top) top = nvars;
241 if (top == 0) return 0;
242 Exponent sum = safe::mult(a[0], wts[0]);
243 for (int i = 1; i < top; i++)
244 sum = safe::add(sum, safe::mult(a[i], wts[i]), "weight overflow");
245 return sum;
246 }
static int32_t mult(int32_t x, int32_t y, const char *msg)
Definition overflow.hpp:236

Referenced by ExponentVector< int, true >::weight().