/* Copyright (c) 1997-2004
   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.
*/

#ident "$Project: polymake $$Id: hypersimplex.cc,v 1.6 2006/02/02 14:43:17 joswig Exp $"

#include <hypersimplex.h>

using namespace polymake;

/** @file hypersimplex
 *
 *  Produce the hypersimplex $&Delta;_d(k)$.
 *  The value of $k$ defaults to 1, yielding a simplex.
 *  Note that the output is never full-dimensional.
 *
 *  @synopsis hypersimplex <file> <d> [<k>]
 *
 *  @writing  AMBIENT_DIM, DIM, N_VERTICES, VERTICES
 *
 *  @index clients Producing from scratch
 */

int main(int argc, const char *argv[]) {
   if (argc != 3 && argc != 4) {
      cerr << "usage: " << argv[0] << " <file> <dimension> [<k>]" << endl;
      return 1;
   }
   try {
      const int d = atoi(argv[2]); // dimension
      if (d < 2) {
	 cerr << argv[0] << ": hypersimplex(d,k): 2 <= d" << endl;
	 return 1;
      }
      const int k = argc==4 ? atoi(argv[3]) : 1;
      if (k < 1 || k > d) {
	 cerr << argv[0] << ": hypersimplex(d,k): 1 <= k <= d" << endl;
	 return 1;
      }

      Poly p(argv[1], ios::out | ios::trunc);
      polytope::hypersimplex(p, d, k);
   }
   catch (const std::exception& e) {
      cerr << e.what() << endl;
      return 1;
   }
   return 0;
}
