Generated on Wed Nov 1 15:04:43 2006 for Gecode by doxygen 1.4.5

binomial.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $
00010  *     $Revision: 3188 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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     //    sar.ensure(n*(n-1)/2);
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 // STATISTICS: set-prop