17 #ifndef AWALI_WEIGHTSET_NK_HH
18 # define AWALI_WEIGHTSET_NK_HH
40 template <
unsigned int K>
48 raise(
"Bounded semirings should have non zero characteristic");
56 std::string
vname(
bool =
true)
const
99 raise(
sname(),
"No division");
105 raise(
sname(),
"No division");
120 return ((l<K)?l:K) == ((
r<K)?
r:K) ;
126 return lhs < rhs && lhs <K;
183 parse(
const std::string & s,
size_t& p) {
185 for(; i>0 && s[i-1]>=
'0' && s[i-1]<=
'9'; --i)
189 std::istringstream st(s.substr(i, p-i));
194 throw parse_exception(
"Weight-Set "+
sname()+
": parsed value ("+s.substr(i, p-i)+
") is too great.");
200 const std::string& =
"text")
211 o <<
"\\mathbb{N}_" << K;
212 else if (
format ==
"text")
215 raise(
"invalid format: ",
format);
220 template<
unsigned version = version::fsm_json>
224 version::check_fsmjson<version>();
236 template<
unsigned version = version::fsm_json>
240 version::check_fsmjson<version>();
249 template<
unsigned version = version::fsm_json>
253 version::check_fsmjson<version>();
virtual int to_int() const
Coerces this node_t to int.
Definition: node.hh:321
object_t * push_back(std::string key, node_t *node)
The semiring of natural numbers bounded by K.
Definition: nn.hh:42
static value_t zero()
Definition: nn.hh:73
static value_t conv(self_type, value_t v)
Definition: nn.hh:165
static std::string sname()
Definition: nn.hh:51
static value_t rdiv(const value_t, const value_t)
Definition: nn.hh:97
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: nn.hh:208
static std::ostream & print(value_t v, std::ostream &o, const std::string &="text")
Definition: nn.hh:199
static bool is_zero(const value_t v)
Definition: nn.hh:135
static value_t add(const value_t l, const value_t r)
Definition: nn.hh:85
static bool equals(const value_t l, const value_t r)
Definition: nn.hh:118
constexpr static bool is_special(value_t)
Definition: nn.hh:129
static value_t parse(const std::string &s, size_t &p)
Definition: nn.hh:183
unsigned int value_t
Definition: nn.hh:68
static constexpr bool show_one()
Definition: nn.hh:148
static value_t one()
Definition: nn.hh:79
json::node_t * value_to_json(value_t v) const
Definition: nn.hh:238
bool finite_t
Definition: nn.hh:69
static value_t conv(std::istream &stream)
Definition: nn.hh:171
static value_t star(const value_t v)
Definition: nn.hh:109
static value_t transpose(const value_t v)
Definition: nn.hh:154
static bool less_than(value_t lhs, value_t rhs)
Whether lhs < rhs.
Definition: nn.hh:124
static constexpr bool is_commutative_semiring()
Definition: nn.hh:146
static nn< K > make(std::istream &is)
Build from the description in is.
Definition: nn.hh:62
static value_t value_from_json(json::node_t const *p)
Definition: nn.hh:251
json::node_t * to_json() const
Definition: nn.hh:222
static size_t hash(value_t v)
Definition: nn.hh:159
static value_t mul(const value_t l, const value_t r)
Definition: nn.hh:91
static constexpr star_status_t star_status()
Definition: nn.hh:151
static bool is_one(const value_t v)
Definition: nn.hh:141
static value_t ldiv(const value_t l, const value_t r)
Definition: nn.hh:103
static const finite_t finite
Definition: nn.hh:70
std::string vname(bool=true) const
Definition: nn.hh:56
The semiring of floating Numbers.
Definition: r.hh:35
star_status_t
The different behaviours a weightset may have with respect to the star.
Definition: enums.hh:163
@ STARRABLE
The star of every element exists.
Definition: enums.hh:165
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
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
std::size_t hash_value(const T &v)
Definition: hash.hh:76
Main namespace of Awali.
Definition: ato.hh:22
Exceptions thrown during parsing.
Definition: parse_exception.hh:26