[Review] Boost.Ratio

So here is my review of Boost.Ratio *- What is your evaluation of the design?* It's a strictly (or at least as struct as possible) implementation of the standard proposal. Code is clear and easily followed. *- What is your evaluation of the implementation?* It's very OK and straightforward. I'll reiterate the question about providing MPL or Fusion adaptors as an optional features (unless I missed them :x) *- What is your evaluation of the documentation?* Good *- What is your evaluation of the potential usefulness of the library?* Ratio fills a gap in the MPl-like data type and enables new interesting design to be done. *- Did you try to use the library? With what compiler? Did you have any problems? * I tried it using gcc 4.4 and 4.5 and icc 11. No problem so far. *- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study? * I quickly glanced over the code as I knew it from its inception and followed it so I only had to look some new stuff. I tried some non trivial task , including some attempt at MPL like CT linear system solver using rational. boost.ratio proved itself useful in this task. *- Are you knowledgeable about the problem domain? * Yes. *- Do you think the library should be accepted as a Boost library?* Yes

----- Original Message ----- From: "joel falcou" <joel.falcou@lri.fr> To: <boost@lists.boost.org> Sent: Friday, October 08, 2010 10:38 PM Subject: [boost] [Review] Boost.Ratio
So here is my review of Boost.Ratio
*- What is your evaluation of the design?* It's a strictly (or at least as struct as possible) implementation of the standard proposal. Code is clear and easily followed.
*- What is your evaluation of the implementation?*
It's very OK and straightforward. I'll reiterate the question about providing MPL or Fusion adaptors as an optional features (unless I missed them :x)
I remember the thread for MPL. I will try to recall it here : The idea is to specialize mpl arithmetic operation for ratio. As Ratio is not a Integral Constants we need to define a new on, let me call it Rational Constant. What could be the requirements for a Rational Constant? Expression Type Complexity r::tag rational_c_tag Constant time. r::value_type A boost::rational<integral_type> type Constant time. r::num An integral constant expression Constant time. r::den An integral constant expression Constant time. r::type Rational Constant Constant time. r::value_type c = r.value() R::value_type Constant time. Expression Semantics r::tag r's tag type; n::tag::value is n's conversion rank. r::num The value of the numerator integral constant. r::den The value of the denominator integral constant. r::type 'is_equivalent'<r::type,r>::value == true. c=r.value() c.numerator() * r::den == c.denominator() * r::num. I could implemented this, but before doing it I will want to heard the maintainers of MPL about this feature and if they will accept to include it in his library. Respect to fusion adaptors, I don't see what can be done. Could detal a little bit more?
*- Did you try to use the library? With what compiler? Did you have any problems? * I tried it using gcc 4.4 and 4.5 and icc 11. No problem so far.
Thanks. I will add icc 11 to the list of comilers.
*- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study? * I quickly glanced over the code as I knew it from its inception and followed it so I only had to look some new stuff. I tried some non trivial task , including some attempt at MPL like CT linear system solver using rational. boost.ratio proved itself useful in this task.
I will be glad to see how you applied ratio. Could you share?
*- Do you think the library should be accepted as a Boost library?* Yes
Thanks Joel. Vicente

On 09/10/10 00:16, vicente.botet wrote:
The idea is to specialize mpl arithmetic operation for ratio. As Ratio is not a Integral Constants we need to define a new on, let me call it Rational Constant. What could be the requirements for a Rational Constant?
Expression Type Complexity r::tag rational_c_tag Constant time. r::value_type A boost::rational<integral_type> type Constant time. r::num An integral constant expression Constant time. r::den An integral constant expression Constant time. r::type Rational Constant Constant time. r::value_type c = r.value() R::value_type Constant time.
Expression Semantics r::tag r's tag type; n::tag::value is n's conversion rank. r::num The value of the numerator integral constant. r::den The value of the denominator integral constant. r::type 'is_equivalent'<r::type,r>::value == true. c=r.value() c.numerator() * r::den == c.denominator() * r::num.
I could implemented this, but before doing it I will want to heard the maintainers of MPL about this feature and if they will accept to include it in his library.
Oh the idea was not to include ratio in MPL but just make ratio expose the needed inner type so you could drop any ratio type into mpl operations.
Respect to fusion adaptors, I don't see what can be done. Could detal a little bit more:
Basically, soemtime I needed to acces the numerator or denominator through fusion::at_c or apply fusion::for_each on them. int n = fusion::at_c<0>( some_ratio ); I can make the adaptor if you want, it's like 20 lines. It can sit in an optional file (much like ratio_io) and be included only if needed.
I will be glad to see how you applied ratio. Could you share? Sure, I'll post this once I go back to my office.

----- Original Message ----- From: "joel falcou" <joel.falcou@lri.fr> To: <boost@lists.boost.org> Sent: Saturday, October 09, 2010 8:16 AM Subject: Re: [boost] [Review] Boost.Ratio
On 09/10/10 00:16, vicente.botet wrote:
The idea is to specialize mpl arithmetic operation for ratio. As Ratio is not a Integral Constants we need to define a new on, let me call it Rational Constant. What could be the requirements for a Rational Constant?
Expression Type Complexity r::tag rational_c_tag Constant time. r::value_type A boost::rational<integral_type> type Constant time. r::num An integral constant expression Constant time. r::den An integral constant expression Constant time. r::type Rational Constant Constant time. r::value_type c = r.value() R::value_type Constant time.
Expression Semantics r::tag r's tag type; n::tag::value is n's conversion rank. r::num The value of the numerator integral constant. r::den The value of the denominator integral constant. r::type 'is_equivalent'<r::type,r>::value == true. c=r.value() c.numerator() * r::den == c.denominator() * r::num.
I could implemented this, but before doing it I will want to heard the maintainers of MPL about this feature and if they will accept to include it in his library.
Oh the idea was not to include ratio in MPL but just make ratio expose the needed inner type so you could drop any ratio type into mpl operations.
As far as I know this the mpl operations could not be compatible with tha Rational constant concept. Please give a depth description of what are you seen that I don't see.
Respect to fusion adaptors, I don't see what can be done. Could detal a little bit more:
Basically, soemtime I needed to acces the numerator or denominator through fusion::at_c or apply fusion::for_each on them.
int n = fusion::at_c<0>( some_ratio );
I can make the adaptor if you want, it's like 20 lines. It can sit in an optional file (much like ratio_io) and be included only if needed.
Please post these lines and I will see if this can be intergrated into Boost.Ratio. Best, Vicente
participants (2)
-
joel falcou
-
vicente.botet