Boost logo

Boost Users :

Subject: Re: [Boost-users] [rational] proposed gcd and lcm for rational
From: Júlio Hoffimann (julio.hoffimann_at_[hidden])
Date: 2011-07-21 07:44:05

Hi Thomas,

Thank you for the intention, but as far as i know, GCD and LCM makes no
sense in the rational field. Any rational number is divisible by all
rationals. For instance, given two rationals b, r in Q, r != 0, you can

b = (b * r^-1) * r

and then b is divisible by r.


2011/7/21 Thomas Taylor <thomas.taylor_at_[hidden]>

> Dear boost users and maintainers,
> As I needed these functions myself I have added a gcd and an lcm for the
> rational type.
> Feel free to do with the code whatever you want, if suitable add it to
> rational.hpp. Presumably this could be reworked as partial specialisation
> of
> boost::math::gcd and boost::math::lcm respectively (if there is a trait
> like
> is_rational).
> HTH,
> Thomas
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at