Class BinomialMatrix¶
Defined in File polynomialUtils.h
Class Documentation¶
-
class
BinomialMatrix
¶ A class that computes binomial coefficients up to a certain power.
The binomial coefficient is defined as:
\[ \left(\begin{array}{ c } n k \end{array}right\) = \frac{n!}{k!(n-k)!} \]with both \(n\) and \(k\) nonnegative integers and \(k \le n\)This class uses recurrence relations to avoid computing factorials directly, making it both more efficient and numerically stable.
Public Functions
-
BinomialMatrix
(int const nMax)¶ Construct an object that can compute binomial coefficients with \(n\) up to and including the given value.
-
double
operator()
(int n, int k) const¶ Return the binomial coefficient.
No error checking is performed; the behavior of this method is is undefined if the given values do not satisfy
n <= nMax && k <= n && n >=0 && k >= 0
-