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

◆ binomial()

ring_elem WeylAlgebra::binomial ( int top,
int bottom ) const
protected

Definition at line 227 of file weylalg.cpp.

228{
229 // This should be located elsewhere
230 // Assumption: bottom <= top, top >= 0, bottom >= 0.
231 if (bottom == 0) return K_->from_long(1);
232 if (bottom == 1) return K_->from_long(top);
233 if (top <= binomtop) return K_->from_long(binomtable[top][bottom]);
234 ring_elem result = K_->from_long(1);
235 for (int a = 0; a < bottom; a++)
236 {
237 ring_elem b = K_->from_long(top - a);
238 ring_elem result1 = K_->mult(result, b);
239 K_->remove(result);
240 K_->remove(b);
241 ring_elem c = K_->from_long(a + 1);
242 result = K_->divide(result1, c); // exact
243 K_->remove(c);
244 }
245 return result;
246}
const Ring * K_
Definition polyring.hpp:123
static int binomtop
Definition weylalg.hpp:69
static int ** binomtable
Definition weylalg.hpp:71
VALGRIND_MAKE_MEM_DEFINED & result(result)

References binomtable, binomtop, PolynomialRing::K_, and result().