1 /* Copyright (c) 1997-2021
2 Ewgenij Gawrilow, Michael Joswig, and the polymake team
3 Technische Universität Berlin, Germany
4 https://polymake.org
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version: http://www.gnu.org/licenses/gpl.txt.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 --------------------------------------------------------------------------------
16 */
17
18 #include "polymake/client.h"
19 #include "polymake/Rational.h"
20 #include "polymake/Matrix.h"
21 #include "polymake/TropicalNumber.h"
22
23 namespace polymake { namespace tropical {
24
25 template <typename Addition>
cyclic(const Int d,const Int n)26 BigObject cyclic(const Int d, const Int n)
27 {
28 if (d<2 || n<=d) {
29 throw std::runtime_error("n > d >= 2 required");
30 }
31 Matrix<TropicalNumber<Addition> > V(n,d+1);
32
33 for (Int i = 0; i < n; ++i)
34 for (Int j = 0; j <= d; ++j)
35 V(i,j)= TropicalNumber<Addition>(Addition::orientation() * i*j);
36 BigObject p("Polytope", mlist<Addition>(), "POINTS", V);
37 p.set_description() << "Tropical cyclic "<<d<<"-polytope with " << n << " vertices"<<endl;
38 return p;
39 }
40
41 UserFunctionTemplate4perl("# @category Producing a tropical polytope"
42 "# Produces a tropical cyclic //d//-polytope with //n// vertices."
43 "# Cf."
44 "# \t Josephine Yu & Florian Block, arXiv: math.MG/0503279."
45 "# @param Int d the dimension"
46 "# @param Int n the number of generators"
47 "# @tparam Addition Min or Max."
48 "# @return Polytope<Addition>"
49 "# @example"
50 "# > $c = cyclic<Min>(3,4);"
51 "# > print $c->VERTICES;"
52 "# | 0 0 0 0"
53 "# | 0 1 2 3"
54 "# | 0 2 4 6"
55 "# | 0 3 6 9",
56 "cyclic<Addition>($,$)");
57 } }
58
59 // Local Variables:
60 // mode:C++
61 // c-basic-offset:3
62 // indent-tabs-mode:nil
63 // End:
64