
Boost : 
From: dherring_at_[hidden]
Date: 20080430 12:25:40
On Wed, 30 Apr 2008, John Maddock wrote:
> dherring_at_[hidden] wrote:
>> On Tue, 29 Apr 2008, John Maddock wrote:
>>
>>> Folks I'm looking for some good names for some functions I'm on the
>>> brink of adding to Boost.Math (all in namespace boost::math::):
>>>
>>> T nextafter(T val, T dir)
>>> T next_greater(T val)
>>> T next_less(T val)
>>
>> Given the first name is fixed, this is a reasonable family of names;
>> though dropping the underscore would increase consistency. However,
>> there
>> is the ambiguity whether greater/less reference zero or infinity.
>
> Not sure what you mean there, next_greater returns a value that is strictly
> greater than the argument (so always moves towards positive infinity).
I confused myself. Standard terminology says < and > are "less than" and
"greater than"; so your names are fine.
Still think the underscore should be dropped for consistency.
>> float x=1.0;
>> float y=2.0;
>> int d=edit_distance(x, y);
>> float z=x;
>> for(int i=0; i<d/2; i++)
>> {
>> z=next_greater(z);
>> }
>> // Does y==(x+z)/2, given the right rounding mode?
>
> Change i<d/2 to i<2*d and yes I believe so.
That was supposed to read
// Does z==(x+y)/2?
Which I think you've answered as yes.
All of these operations apply to integers (albeit in the trivial sense
that i and i+1 are always separated by a single gap). Thus it might be
nice if these operators could be applied to all numeric types, integers
and floatingpoint.
Thanks,
Daniel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk