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