/* Copyright (c) 1997-2010
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
   http://www.polymake.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.
--------------------------------------------------------------------------------
   $Project: polymake $$Id: cyclic.cc 9991 2010-12-12 23:36:28Z gawrilow $
*/

#include "polymake/client.h"
#include "polymake/Rational.h"
#include "polymake/Matrix.h"

namespace polymake { namespace tropical {

perl::Object cyclic(const int d, const int n)
{
   if (d<2 || n<=d) {
      throw std::runtime_error("n > d >= 2 required");
   }
   Matrix<Rational> V(n,d+1);

   for (int i=0; i<n; ++i)
      for (int j=0; j<=d; ++j)
         V(i,j)=i*j;
   perl::Object p("TropicalPolytope<Rational>");
   p.set_description()<<"Tropical cyclic "<<d<<"-polytope with "<<n<< " vertices"<<endl;
   p.take("POINTS") << V;
   return p;
}

UserFunction4perl("# @category Producing from scratch"
                  "# Produces a tropical cyclic //d//-polytope with //n// vertices."
                  "# Cf."
                  "#    Josephine Yu & Florian Block, arXiv: math.MG/0503279."
                  "# @param int d the dimension"
                  "# @param int n the number of generators"
                  "# @return TropicalPolytope",
                  &cyclic,"cyclic");
} }

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