17 #ifndef AWALI_WEIGHTSET_ZMAX_HH
18 # define AWALI_WEIGHTSET_ZMAX_HH
50 std::string
vname(
bool =
true)
const
96 raise(
sname(),
": star: invalid value: ",
format(*
this, v));
172 switch (
int i = stream.peek())
176 if ( stream.peek() ==
'o' ) {
178 if ( stream.get() ==
'o')
181 throw std::domain_error(
sname() +
": invalid value: -o" +
str_escape(i));
192 parse(
const std::string & s,
size_t& p) {
193 if (p>=3 && s[p-3]==
'-' && s[p-2]==
'o' && s[p-1]==
'o'){
198 for(; i>0 && s[i-1]>=
'0' && s[i-1]<=
'9'; --i)
202 if(i>0 && (s[i-1]==
'-' || s[i-1]==
'+'))
204 std::istringstream st(s.substr(i, p-i));
213 const std::string&
format =
"text")
223 o << (
format ==
"latex" ?
"-\\infty" :
"-oo");
233 o <<
"\\mathbb{Z}_{max}";
234 else if (
format ==
"text")
237 raise(
"invalid format: ",
format);
241 template<
unsigned version = version::fsm_json>
245 version::check_fsmjson<version>();
257 std::stringstream ss;
259 <<
" node cannot be coerced to a Z-max-plus value.";
264 template<
unsigned version = version::fsm_json>
280 template<
unsigned version = version::fsm_json>
Exception used when trying to coerce a node to a given type.
Definition: node.hh:143
path_t path_to_root() const
virtual std::string to_string() const
Coerces this node_t to an std::string.
Definition: node.hh:331
virtual int to_int() const
Coerces this node_t to int.
Definition: node.hh:321
The Boolean semring.
Definition: b.hh:38
bool value_t
Definition: b.hh:56
The semiring of floating Numbers.
Definition: r.hh:35
The Z-max-plus semiring.
Definition: zmax.hh:41
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: zmax.hh:230
static value_t zero()
Definition: zmax.hh:106
static value_t one()
Definition: zmax.hh:100
static value_t conv(std::istream &stream)
Definition: zmax.hh:169
static value_t conv(self_type, value_t v)
Definition: zmax.hh:157
json::node_t * value_to_json(value_t v) const
Definition: zmax.hh:266
static value_t parse(const std::string &s, size_t &p)
Definition: zmax.hh:192
constexpr static bool is_special(value_t)
Definition: zmax.hh:123
static bool is_one(const value_t v)
Definition: zmax.hh:135
std::string vname(bool=true) const
Definition: zmax.hh:50
static zmax make(std::istream &is)
Build from the description in is.
Definition: zmax.hh:56
int value_t
Definition: zmax.hh:62
static value_t conv(b, b::value_t v)
Definition: zmax.hh:163
static std::string sname()
Definition: zmax.hh:45
static constexpr bool show_one()
Definition: zmax.hh:142
static std::ostream & print(const value_t v, std::ostream &o, const std::string &format="text")
Definition: zmax.hh:212
value_t star(const value_t v) const
Definition: zmax.hh:91
static value_t rdiv(const value_t l, const value_t r)
Definition: zmax.hh:78
static value_t transpose(const value_t v)
Definition: zmax.hh:146
static constexpr bool is_commutative_semiring()
Definition: zmax.hh:140
static value_t add(const value_t l, const value_t r)
Definition: zmax.hh:65
static size_t hash(value_t v)
Definition: zmax.hh:151
static bool equals(const value_t l, const value_t r)
Definition: zmax.hh:112
static constexpr star_status_t star_status()
Definition: zmax.hh:143
static bool is_zero(const value_t v)
Definition: zmax.hh:129
static value_t mul(const value_t l, const value_t r)
Definition: zmax.hh:71
json::node_t * to_json() const
Definition: zmax.hh:282
static bool less_than(value_t lhs, value_t rhs)
Whether lhs < rhs.
Definition: zmax.hh:118
static value_t ldiv(const value_t l, const value_t r)
Definition: zmax.hh:85
static value_t value_from_json(json::node_t const *p)
Definition: zmax.hh:243
star_status_t
The different behaviours a weightset may have with respect to the star.
Definition: enums.hh:163
@ TOPS
Definition: enums.hh:167
std::string to_string(identities i)
void eat(std::istream &is, char c)
Check lookahead character and advance.
Definition: stream.hh:62
ATTRIBUTE_NORETURN void fail_reading(std::istream &is, std::string explanation)
Throw an exception after failing to read from is.
Definition: stream.hh:93
auto join(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< join_t< Ctx1, Ctx2 >>
The union of two ratexpsets.
Definition: ratexpset.hh:445
std::ostream & str_escape(std::ostream &os, const int c)
Definition: escape.hh:30
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
void require(bool b, Args &&... args)
If b is not verified, raise an error with args as message.
Definition: raise.hh:55
std::size_t hash_value(const T &v)
Definition: hash.hh:76
ATTRIBUTE_CONST int max(int a, int b)
Definition: arith.hh:54
ATTRIBUTE_CONST int min(int a, int b)
Definition: arith.hh:48
Main namespace of Awali.
Definition: ato.hh:22
Exceptions thrown during parsing.
Definition: parse_exception.hh:26