55 return value_t{mpz_class(0), 1};
73 auto num = std::numeric_limits<int>::max();
107 if (
abs(v.get_num()) < v.get_den())
109 return {v.get_den(), v.get_den() - v.get_num()};
121 return v.get_num() == 0;
127 return v.get_num() == 1 && v.get_den() == 1;
184 conv(std::istream& i,
bool =
true)
197 if (v.get_den() == 1)
200 o <<
"\\frac{" << v.get_num() <<
"}{" << v.get_den() <<
'}';
213 o <<
"\\mathbb{Q}_{\\text{mp}}";
233 template <
typename RandomGenerator>
241 using super_t::super_t;
247 std::uniform_int_distribution<>(super_t::min_.get_num().get_ui(),
248 super_t::max_.get_num().get_ui());
250 std::uniform_int_distribution<unsigned>
251 (super_t::min_.get_den().get_ui(),
252 super_t::max_.get_num().get_ui());
253 auto num = dis_num(super_t::gen_);
254 auto den = dis_den(super_t::gen_);
255 return super_t::ws_.value(num, den);
static value_t value(int num, unsigned den)
Create rational weight from num and den.
Print as is. For instance, don't try to escape labels.
char eat(std::istream &is, char c)
Check lookahead character and advance.
Print as a parsable type string.
Generic declaration of the class which is specialized in each weightset.
static constexpr star_status_t star_status()
static constexpr bool is_commutative()
static qmp make(std::istream &is)
Build from the description in is.
static value_t abs(const value_t &v)
static bool is_one(const value_t &v)
value_t star(const value_t &v) const
An input/output format for valuesets.
Abstract class for random weight generation.
weightset_mixin< detail::r_impl > r
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
Provide a variadic mul on top of a binary mul(), and one().
weightset_mixin< detail::qmp_impl > qmp
static size_t hash(value_t v)
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
static value_t conv(b, b::value_t v)
typename super_t::weight_t value_t
static value_t conv(std::istream &i, bool=true)
value_t rdivide(const value_t &l, const value_t &r) const
static value_t conv(self_t, value_t v)
static bool less(value_t l, value_t r)
Whether < r.
static constexpr bool show_one()
Print as rich UTF-8 text, escaped.
static value_t sub(const value_t &l, const value_t &r)
static constexpr bool has_lightening_weights()
std::ostream & print_set(std::ostream &o, format fmt={}) const
Print as plain (ASCII) text, escaped.
static value_t transpose(const value_t &v)
valid iff proper succeeds on the "absolute value" of the automaton
typename qmp::value_t weight_t
static bool equal(const value_t &l, const value_t &r)
std::string to_string(direction d)
Conversion to string.
static value_t conv(z, z::value_t v)
value_t ldivide(const value_t &l, const value_t &r) const
static bool is_zero(const value_t &v)
ATTRIBUTE_NORETURN void raise_not_starrable(const WeightSet &ws, const typename WeightSet::value_t &w)
This value is not starrable.
static value_t mul(const value_t &l, const value_t &r)
static bool is_special(const value_t &)
value_t pick_value_() const
static value_t add(const value_t &l, const value_t &r)
static std::ostream & print(const value_t &v, std::ostream &o=std::cout, format fmt={})