Vcsn  2.3
Be Rational
rmin.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/core/join.hh>
4 #include <vcsn/misc/raise.hh>
5 #include <vcsn/misc/stream.hh> // eat
6 #include <vcsn/weightset/fwd.hh>
8 #include <vcsn/weightset/nmin.hh>
10 #include <vcsn/weightset/zmin.hh>
11 
12 namespace vcsn
13 {
14  namespace detail
15  {
16  class rmin_impl
17  : public min_plus_impl<rmin_impl, double>
18  {
19  public:
21  using self_t = rmin;
22  using value_t = typename super_t::value_t;
23 
24  static symbol sname()
25  {
26  static auto res = symbol{"rmin"};
27  return res;
28  }
29 
31  static rmin make(std::istream& is)
32  {
33  eat(is, sname());
34  return {};
35  }
36 
37  using super_t::conv;
38  static value_t
40  {
41  return v;
42  }
43 
44  static value_t
46  {
47  return v;
48  }
49 
50  static value_t
52  {
53  return v;
54  }
55 
56  static constexpr bool has_lightening_weights() { return true; }
57 
58  std::ostream&
59  print_set(std::ostream& o, format fmt = {}) const
60  {
61  switch (fmt.kind())
62  {
63  case format::latex:
64  o << "\\mathbb{R}_{\\text{min}}";
65  break;
66  case format::sname:
67  o << sname();
68  break;
69  case format::text:
70  o << "Rmin";
71  break;
72  case format::utf8:
73  o << "ℝmin";
74  break;
75  case format::raw:
76  assert(0);
77  break;
78  }
79  return o;
80  }
81  };
82 
87  }
88 
89  template <>
90  struct is_tropical<rmin> : std::true_type
91  {};
92 }
static rmin make(std::istream &is)
Build from the description in is.
Definition: rmin.hh:31
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Definition: symbol.hh:23
std::ostream & print_set(std::ostream &o, format fmt={}) const
Definition: rmin.hh:59
typename super_t::value_t value_t
Definition: rmin.hh:22
static constexpr bool has_lightening_weights()
Definition: rmin.hh:56
Print as a parsable type string.
Definition: format.hh:26
static value_t conv(self_t, value_t v)
Definition: rmin.hh:39
return res
Definition: multiply.hh:398
weightset_mixin< detail::rmin_impl > rmin
Definition: fwd.hh:55
static symbol sname()
Definition: rmin.hh:24
weightset_mixin< detail::zmin_impl > zmin
Definition: fwd.hh:57
VCSN_JOIN_SIMPLE(b, b)
Definition: a-star.hh:8
An input/output format for valuesets.
Definition: format.hh:13
Print as is. For instance, don't try to escape labels.
Definition: format.hh:24
weightset_mixin< detail::nmin_impl > nmin
Definition: fwd.hh:51
static value_t conv(zmin, const zmin::value_t v)
Definition: rmin.hh:51
Print as rich UTF-8 text, escaped.
Definition: format.hh:30
weightset_mixin< detail::b_impl > b
Definition: fwd.hh:48
static value_t conv(nmin, const nmin::value_t v)
Definition: rmin.hh:45
Print for LaTeX.
Definition: format.hh:22
static value_t conv(b, b::value_t v)
Definition: min-plus.hh:127
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
Print as plain (ASCII) text, escaped.
Definition: format.hh:28
char eat(std::istream &is, char c)
Check lookahead character and advance.
Definition: stream.cc:90