17 #ifndef AWALI_WEIGHTSET_F_HH
18 # define AWALI_WEIGHTSET_F_HH
38 template <
unsigned int N>
45 raise(
"Cyclic semirings should have a characteristic larger than 1");
53 std::string
vname(
bool =
true)
const
104 for (
unsigned i=1; i<N; i++) {
111 throw std::runtime_error(
sname()+
": unreachable code");
126 throw std::domain_error(
"Weightset "+
sname()+
": given value ("+
std::to_string(v)+
") is not starrable");
138 return lhs%N < rhs%N;
149 return ( (v%N) == 0);
155 return ( (v%N) == 1);
195 parse(
const std::string & s,
size_t& p) {
197 for(; i>0 && s[i-1]>=
'0' && s[i-1]<=
'9'; --i)
201 std::istringstream st(s.substr(i, p-i));
206 throw parse_exception(
"Weight-Set "+
sname()+
": parsed value ("+s.substr(i, p-i)+
") is too great.");
212 const std::string& =
"text")
221 o <<
"\\mathbb{F}_" << N;
222 else if (
format ==
"text")
223 o <<
"Z/" << N <<
'Z';
225 raise(
"invalid format: ",
format);
230 template<
unsigned version = version::fsm_json>
234 version::check_fsmjson<version>();
247 template<
unsigned version = version::fsm_json>
251 version::check_fsmjson<version>();
261 template<
unsigned version = version::fsm_json>
266 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 floating Numbers.
Definition: r.hh:35
The cyclic semiring with characteristic N.
Definition: zz.hh:39
static constexpr bool show_one()
Definition: zz.hh:160
static bool less_than(value_t lhs, value_t rhs)
Whether lhs < rhs.
Definition: zz.hh:136
static value_t add(const value_t l, const value_t r)
Definition: zz.hh:82
static value_t mul(const value_t l, const value_t r)
Definition: zz.hh:94
static size_t hash(value_t v)
Definition: zz.hh:171
static value_t star(const value_t v)
Definition: zz.hh:121
static constexpr bool is_commutative_semiring()
Definition: zz.hh:158
static bool is_one(const value_t v)
Definition: zz.hh:153
value_t value_from_json(json::node_t const *p) const
Definition: zz.hh:263
static value_t rdiv(const value_t l, const value_t r)
Definition: zz.hh:100
json::node_t * value_to_json(value_t v) const
Definition: zz.hh:248
bool finite_t
Definition: zz.hh:66
static value_t zero()
Definition: zz.hh:70
static constexpr star_status_t star_status()
Definition: zz.hh:163
std::string vname(bool=true) const
Definition: zz.hh:53
static value_t one()
Definition: zz.hh:76
static json::node_t * to_json()
Definition: zz.hh:232
static std::ostream & print(const value_t v, std::ostream &o, const std::string &="text")
Definition: zz.hh:211
static std::string sname()
Definition: zz.hh:48
static bool equals(const value_t l, const value_t r)
Definition: zz.hh:130
static value_t parse(const std::string &s, size_t &p)
Definition: zz.hh:195
static value_t ldiv(const value_t l, const value_t r)
Definition: zz.hh:115
static value_t transpose(const value_t v)
Definition: zz.hh:166
static value_t conv(std::istream &stream)
Definition: zz.hh:183
static value_t sub(const value_t l, const value_t r)
Definition: zz.hh:88
static value_t conv(self_type, value_t v)
Definition: zz.hh:177
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: zz.hh:218
constexpr static bool is_special(value_t)
Definition: zz.hh:141
static bool is_zero(const value_t v)
Definition: zz.hh:147
static const finite_t finite
Definition: zz.hh:67
static zz< N > make(std::istream &is)
Build from the description in is.
Definition: zz.hh:59
int value_t
Definition: zz.hh:65
star_status_t
The different behaviours a weightset may have with respect to the star.
Definition: enums.hh:163
@ NON_STARRABLE
Definition: enums.hh:166
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
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
Main namespace of Awali.
Definition: ato.hh:22
Exceptions thrown during parsing.
Definition: parse_exception.hh:26