[MPL.Math] numeric concepts

--- Andy Little wrote:
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 an "mpl rational or numeric concept"?
In my yet-to-be-submitted documentation, I have the following numeric metatype hierarchy: Numeric Constant | +--Real Numeric Constant | | | +--Discrete Constant--Bitwise Constant | | | | | | +--Integral Constant------+ | | | | | | +--Big Integral Constant--+ | | | +--Continuous Constant | | | +--Rational Constant | | | +--Mixed Numeric Constant | +--Complex Numeric Constant Each concept is defined in terms of the metafunctions that can operate on it, and their semantics. In this scheme, both Integral Constants and Rational Constants are Real Numeric Constants. Not only do the arithmetic metafunctions (negate, plus, minus, times, divides), a few comparison metafunctions (equal_to, not_equal_to), and a few numeric metafunctions (is_zero, zero, real_part, imaginary_part) work on them as they do on other Numeric Constants; but all the other comparison metafunctions (less, greater, less_equal, greater_equal) and all the other numeric metafunctions (is_negative, abs, numerator, denominator, whole_part, fractional_part) work on them as well. A few metafunctions have different semantics for Discrete Constants; e.g. the numerator or whole_part of an Integral Constant is itself, its denominator is always one, and its fractional_part is always zero. To obtain the corresponding run-time values, use the runtime_value facility, which is required to operate on all Numeric Constants. Let me know of any details that need to be fleshed out for you. Cromwell D. Enage __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com

--- Cromwell Enage wrote:
A few metafunctions have different semantics for for Discrete Constants; e.g. the numerator or whole_part of an Integral Constant is itself,
Errata: the metafunctions return the absolute value of the Integral Constant; use is_negative to retrieve the sign. Cromwell D. Enage __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs

Cromwell Enage wrote:
--- Cromwell Enage wrote:
A few metafunctions have different semantics for for Discrete Constants; e.g. the numerator or whole_part of an Integral Constant is itself,
Errata: the metafunctions return the absolute value of the Integral Constant; use is_negative to retrieve the sign.
Cromwell D. Enage
Ouch! wrt to an earlier post - I'd be expecting the sign to be retained. I have a good hint of why you might have gone down this path, but I can only think that its going to be cause for error. Cheers, -- Manfred Doudar MetOcean Engineers www.metoceanengineers.com
participants (2)
-
Cromwell Enage
-
Manfred Doudar