binomial.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "gecode/set.hh"
00023 #include "gecode/set/distinct/binomial.icc"
00024
00025 namespace Gecode { namespace Set { namespace Distinct {
00026
00027 void
00028 Binomial::init(unsigned int n) {
00029 int n2 = (n-2)/2;
00030 int nn = n2*(n2-1);
00031 nn += n2;
00032 if (n % 2 == 1)
00033 nn += n2;
00034
00035
00036 sar.ensure(nn);
00037 unsigned int oldnmax = nmax;
00038 nmax = n;
00039 for (unsigned int i=oldnmax+1; i<=n; i++)
00040 for (unsigned int j=2; j<=(i/2); j++)
00041 y(i, j, y(i-1, j-1) + y(i-1, j));
00042 }
00043
00044 }}}
00045
00046