[MPL.Math] rational_part or fractional_part?

--- Daryle Walker wrote:
Is BOOST_MPL_MATH_RATIONAL_PART_OF_RATIONAL a re-statement of the rational number itself?
No.
Or is it supposed to be the remainder after taking out the "whole" part?
Yes.
If the latter, then the name should have "FRACTIONAL" replacing the first "RATIONAL", since "fractional" and not "rational" better describes a left-over bit.
(Rational numbers are a generalization of fractions that include values with absolute values greater
For consistency this part of the macro name is lexically the same as the template name whose specialization the macro creates, i.e. rational_part. than
one, i.e. a numerator larger than its denominator [in absolute value].)
I have no qualms about changing the name, as long as all interested parties agree. Andy Little? Cromwell D. Enage __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com

Cromwell Enage <sponage@yahoo.com> writes:
--- Daryle Walker wrote:
Is BOOST_MPL_MATH_RATIONAL_PART_OF_RATIONAL a re-statement of the rational number itself?
No.
Or is it supposed to be the remainder after taking out the "whole" part?
Yes.
If the latter, then the name should have "FRACTIONAL" replacing the first "RATIONAL", since "fractional" and not "rational" better describes a left-over bit.
For consistency this part of the macro name is lexically the same as the template name whose specialization the macro creates, i.e. rational_part.
Both names seems misleading to me. What's wrong with BOOST_MPL_MATH_RATIONAL_FRACTIONAL_PART fractional_part ?? -- Dave Abrahams Boost Consulting www.boost-consulting.com

"Cromwell Enage" wrote
I have no qualms about changing the name, as long as all interested parties agree. Andy Little?
Shouldnt the two parts be described as integer_part and fractional_part ? And also ... Why do they need to be macros? BTW I have found that the ability to convert a rational to an integral_constant if possible is a useful utility too, though I'm not quite sure what purists would make of it as the resulting ::type may be an integral_constant or maybe a rational constant. I currently call it "simplify_rational_or_numeric". The resulting ::type works ok if accessed using the numerator and denominator functions, and this allows me to make lists of dimensions using both integral_constants and rationals. Maybe there is room for such a concept as a "mpl rational or numeric concept" ? Also, Cromwell, do you think that rational numerator and denominator should be evaluated eagerly ( as it currently is) or alternatively lazily, so that it would need some function to normalise the rational before or maybe during math? (FWIW my vote is to stay with current behaviour though using rational<nyumerator,denominator> for ::type member.) Meanwhile keep up the good work.. regards Andy Little

--- Andy Little wrote:
Shouldn't the two parts be described as integer_part and fractional_part?
IMHO integer_part is not as descriptive as whole_part.
And also ... Why do they need to be macros?
The default implementations of whole_part and rational_part assume that the numeric constant is already a Mixed Number, with nested whole_part and rational_part typedefs. Any numeric constant that wants to be treated as a Mixed Number but can't provide these typedefs (e.g. double_c) must provide the necessary metafunction class specializations. However, for Rational Constants, whole_part and rational_part can be specialized in terms of the numerator and denominator metafunctions. If there are at least two such models of Rational Constants, the specialization code of whole_part and rational_part would have to be duplicated for each model. The macros are there to minimize this duplication. The same goes for the numerator and denominator of Mixed Numbers. [snip concepts discussion, started on new thread]
Also, Cromwell, do you think that rational numerator and denominator should be evaluated eagerly (as it currently is) or alternatively lazily, so that it would need some function to normalise the rational before or maybe during math?
I've exposed simplified_rational for use by those metafunctions that are guaranteed to return relatively prime numerators and denominators, e.g. rational_part_impl<double_tag>::apply. Those numeric metafunctions that cannot provide this guarantee must use either rational or rational_::simplify.
(FWIW my vote is to stay with current behaviour though using rational<numerator,denominator> for ::type member.)
Is the current definition sufficient? template <typename N, typename D> struct rational : rational_::simplify<N,D>::type { };
Meanwhile keep up the good work..
Thanks! Cromwell D. Enage __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com

Cromwell Enage <sponage@yahoo.com> writes:
--- Andy Little wrote:
Shouldn't the two parts be described as integer_part and fractional_part?
IMHO integer_part is not as descriptive as whole_part.
whole_part sounds like an oxymoron, and will surely be confusing. integer_part is common usage. It doesn't matter if you don't think it's descriptive; everyone will understand it... unless of course you mean something different from what everybody means by "integer part." -- Dave Abrahams Boost Consulting www.boost-consulting.com

--- David Abrahams wrote:
whole_part sounds like an oxymoron, and will surely be confusing.
To be honest, I never saw whole_part as an oxymoron before.
integer_part is common usage. It doesn't matter if you don't think it's descriptive; everyone will understand it...
Okay, if everyone understands it, then that's what I'll use.
unless of course you mean something different from what everybody means by "integer part."
I was thinking that integer_part included the sign and whole_part didn't. Cromwell D. Enage __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com

Cromwell Enage wrote:
--- David Abrahams wrote:
integer_part is common usage. It doesn't matter if you don't think it's descriptive; everyone will understand it...
Okay, if everyone understands it, then that's what I'll use.
unless of course you mean something different from what everybody means by "integer part."
I was thinking that integer_part included the sign and whole_part didn't.
That's a little scary; integer_part, and fractional_part ... are ideal names, BUT I would expect that both integer and fractional _parts *included* the sign - and I tend to think anything else would inevitably lead to confusion. There of course are complementary calls like `abs` and `sign` which should assuage all. Cheers, -- Manfred Doudar MetOcean Engineers www.metoceanengineers.com

Cromwell Enage <sponage@yahoo.com> writes:
I was thinking that integer_part included the sign
Well, it probably does.
and whole_part didn't.
I see. I'm not sure that's a good enough reason for "whole_part," but I can understand your reasoning. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (5)
-
Andy Little
-
Cromwell Enage
-
David Abrahams
-
Jason Hise
-
Manfred Doudar