67 static unsigned abs(
int a)
69 return a < 0 ? -a : a;
90 auto num = std::numeric_limits<int>::max();
166 return v.
num == 1 && v.
den == 1;
177 return lhs.
num *
static_cast<long>(rhs.
den)
178 < rhs.
num * static_cast<long>(lhs.
den);
226 conv(std::istream& i,
bool =
true)
const
230 raise(*
this,
": invalid numerator: ", i);
249 raise(*
this,
": invalid denominator: ", i);
251 require(den, *
this,
": null denominator");
267 o <<
"\\frac{" << v.
num <<
"}{" << v.
den <<
'}';
304 template <
typename RandomGenerator>
312 using super_t::super_t;
318 = std::uniform_int_distribution<>(super_t::min_.num,
321 = std::uniform_int_distribution<unsigned>(super_t::min_.den,
323 auto num = dis_num(super_t::gen_);
324 auto den = dis_den(super_t::gen_);
325 return super_t::ws_.value(num, den);
value_t & reduce()
Put it in normal form.
Print as is. For instance, don't try to escape labels.
char eat(std::istream &is, char c)
Check lookahead character and advance.
static value_t mul(const value_t &l, const value_t &r)
Print as a parsable type string.
Generic declaration of the class which is specialized in each weightset.
static value_t conv(z, const z::value_t v)
static bool less(const value_t &lhs, const value_t &rhs)
Whether lhs < rhs.
value_t rgcd(const value_t &l, const value_t &r) const
static value_t conv(self_t, const value_t &v)
ATTRIBUTE_PURE unsigned int lcm(unsigned int a, unsigned int b)
Lowest common multiple.
static unsigned abs(int a)
static size_t hash(const value_t &v)
ATTRIBUTE_PURE unsigned int gcd(unsigned int a, unsigned int b)
Greatest common divisor.
An input/output format for valuesets.
Abstract class for random weight generation.
static value_t conv(b, const b::value_t v)
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().
static constexpr bool show_one()
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
static constexpr bool is_commutative()
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
static value_t sub(const value_t &l, const value_t &r)
value_t star(const value_t &v) const
value_t(int n=0, unsigned d=1)
static bool is_special(const value_t &)
static bool equal(const value_t &l, const value_t &r)
typename super_t::weight_t value_t
Print as rich UTF-8 text, escaped.
static value_t abs(const value_t &v)
static value_t value(int num, unsigned den)
Create rational weight from num and den.
Print as plain (ASCII) text, escaped.
static std::ostream & print(const value_t &v, std::ostream &o=std::cout, format fmt={})
weightset_mixin< detail::q_impl > q
static q make(std::istream &is)
Build from the description in is.
value_t ldivide(const value_t &l, const value_t &r) const
valid iff proper succeeds on the "absolute value" of the automaton
typename q::value_t weight_t
std::ostream & print_set(std::ostream &o, format fmt={}) const
ATTRIBUTE_NORETURN void raise_not_starrable(const WeightSet &ws, const typename WeightSet::value_t &w)
This value is not starrable.
static value_t add(const value_t &l, const value_t &r)
value_t conv(std::istream &i, bool=true) const
value_t lgcd(const value_t &l, const value_t &r) const
GCD: arbitrarily the first argument.
static bool is_one(const value_t &v)
void hash_combine(std::size_t &seed, const T &v)
static bool is_zero(const value_t &v)
value_t pick_value_() const
static constexpr bool has_lightening_weights()
static value_t transpose(const value_t &v)
static constexpr star_status_t star_status()
value_t rdivide(const value_t &l, const value_t &r) const