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;
232 conv(std::istream& i,
bool =
true)
const 236 raise(*
this,
": invalid numerator: ", i);
255 raise(*
this,
": invalid denominator: ", i);
257 require(den, *
this,
": null denominator");
273 o <<
"\\frac{" << v.
num <<
"}{" << v.
den <<
'}';
310 template <
typename RandomGenerator>
318 using super_t::super_t;
324 = std::uniform_int_distribution<>(super_t::min_.num,
327 = std::uniform_int_distribution<unsigned>(super_t::min_.den,
329 auto num = dis_num(super_t::gen_);
330 auto den = dis_den(super_t::gen_);
331 return super_t::ws_.value(num,
den);
static bool is_special(const value_t &)
Print as a parsable type string.
static value_t mul(const value_t &l, const value_t &r)
static value_t transpose(const value_t &v)
static value_t value(int num, unsigned den)
Create rational weight from num and den.
static value_t conv(z, const z::value_t v)
value_t pick_value_() const
static std::ostream & print(const value_t &v, std::ostream &o=std::cout, format fmt={})
static value_t add(const value_t &l, const value_t &r)
char eat(std::istream &is, char c)
Check lookahead character and advance.
ATTRIBUTE_PURE unsigned int lcm(unsigned int a, unsigned int b)
Lowest common multiple.
static bool less(const value_t &l, const value_t &r)
Whether l < r.
value_t(int n=0, unsigned d=1)
static bool is_zero(const value_t &v)
weightset_mixin< detail::q_impl > q
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
valid iff proper succeeds on the "absolute value" of the automaton
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().
static bool equal(const value_t &l, const value_t &r)
Whether l == r.
static value_t conv(self_t, const value_t &v)
typename super_t::weight_t value_t
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
static unsigned abs(int a)
static size_t hash(const value_t &v)
value_t star(const value_t &v) const
value_t lgcd(const value_t &l, const value_t &r) const
GCD: arbitrarily the first argument.
Print as plain (ASCII) text, escaped.
static value_t conv(b, const b::value_t v)
value_t rdivide(const value_t &l, const value_t &r) const
static int compare(const value_t &l, const value_t &r)
Three-way comparison between l and r.
value_t conv(std::istream &i, bool=true) const
ATTRIBUTE_NORETURN void raise_not_starrable(const WeightSet &ws, const typename WeightSet::value_t &w)
This value is not starrable.
static constexpr bool show_one()
static constexpr bool is_commutative()
Print as is. For instance, don't try to escape labels.
ATTRIBUTE_PURE unsigned int gcd(unsigned int a, unsigned int b)
Greatest common divisor.
static bool is_one(const value_t &v)
void hash_combine(std::size_t &seed, const T &v)
static value_t abs(const value_t &v)
static constexpr star_status_t star_status()
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 value_t sub(const value_t &l, const value_t &r)
std::ostream & print_set(std::ostream &o, format fmt={}) const
typename weightset_t::value_t weight_t
static q make(std::istream &is)
Build from the description in is.
value_t ldivide(const value_t &l, const value_t &r) const
value_t & reduce()
Put it in normal form.
static constexpr bool has_lightening_weights()
value_t rgcd(const value_t &l, const value_t &r) const