Simpatico  v1.10
Binomial.h
1 #ifndef UTIL_BINOMIAL_H
2 #define UTIL_BINOMIAL_H
3 
4 /*
5 * Util Package - C++ Utilities for Scientific Computation
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/containers/GArray.h> // base class
12 #include <util/math/Rational.h> // default template argument
13 #include <util/containers/Array.h> // function argument
14 #include <util/global.h>
15 
16 
17 #include <iostream>
18 
19 namespace Util
20 {
21 
27  class Binomial
28  {
29 
30  public:
31 
39  static void setup(int nMax);
40 
51  static int coeff(int n, int m);
52 
53  private:
54 
58  static GArray<int> coeffs_;
59 
63  static int maxN_;
64 
68  Binomial();
69 
70  };
71 
72 }
73 #endif
static int coeff(int n, int m)
Return coefficient "n choose m", or C(n, m) = n!/(m!(n-m)!).
Definition: Binomial.cpp:47
File containing preprocessor macros for error handling.
static void setup(int nMax)
Precompute all combinations C(n, m) up to n = nMax.
Definition: Binomial.cpp:17
Class for binomial coefficients (all static members)
Definition: Binomial.h:27
Utility classes for scientific computation.
Definition: accumulators.mod:1