/* Copyright (c) 1997-2006
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
   http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version: http://www.gnu.org/licenses/gpl.txt.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
*/

#ifndef _POLYMAKE_HYPERSIMPLEX_H
#define _POLYMAKE_HYPERSIMPLEX_H "$Project: polymake $$Id: hypersimplex.h 7182 2006-03-09 16:21:36Z gawrilow $"

#include <cstdlib>
#include <Poly.h>
#include <Rational.h>
#include <Matrix.h>
#include <PowerSet.h>

namespace polymake { namespace polytope {

void hypersimplex(Poly& p, int d, int k)
{
   // we have the dimensionality information (twice)
   p.take("AMBIENT_DIM") << d+1;
   p.take("DIM") << d;

   // we already know the number of vertices
   const int n=Integer::binom(d+1,k);
   p.take("N_VERTICES") << n;

   Matrix<Rational> Vertices(n,d+2);
   Rows< Matrix<Rational> >::iterator v=rows(Vertices).begin();
   Subsets_of_k<sequence> enumerator(range(1,d+1), k);
   for (Subsets_of_k<sequence>::iterator s=entire(enumerator); !s.at_end(); ++s, ++v) {
      (*v)[0]=1;
      v->slice(*s).fill(1);
   }
   p.take("VERTICES") << Vertices;
}

} }

#endif // _POLYMAKE_HYPERSIMPLEX_H

// Local Variables:
// mode:C++
// c-basic-offset:3
// End:


syntax highlighted by Code2HTML, v. 0.9.1