

Dear colleagues,
If this is not already the case, would you please consider making
directed rounding, as made available on all IEEE 747 compliant
processors, simply accessible to gnuoctave users? This would help
assessing the number of significant digits in the results of
floattingpoint computation.
Best regards,
Eric Walter


On Thu, Sep 17, 2015 at 4:47 PM, Eric Walter
< [hidden email]> wrote:
> Dear colleagues,
>
> If this is not already the case, would you please consider making directed
> rounding, as made available on all IEEE 747 compliant processors, simply
> accessible to gnuoctave users? This would help assessing the number of
> significant digits in the results of floattingpoint computation.
>
> Best regards,
>
> Eric Walter
>
Dear Eric,
I might not get the point correctly, but are the functions round, fix,
floor, ceil, sign, chop not doing what you need?


Dear Juan Pablo,
Thanks for your quick reaction. What I need is a simple way of
computing the smallest floatting point number that is larger
than some given real number that may be the result of some
computation, as well as the largest floatting point number that is
smaller that the same real number. This corresponds to two of the
four rounding modes demanded by IEEE 747. As far as I know, none of
the functions that you mention perform that. MATLAB does not do it,
Scilab does not do it either. To see how these rounding modes may be
used to assess number of significant digits, you may consult chapter
14 of the book
http://www.springer.com/fr/book/9783319076706#reviews
Best,
Eric
Le 17/09/2015 17:43, Juan Pablo
Carbajal a écrit :
On Thu, Sep 17, 2015 at 4:47 PM, Eric Walter
[hidden email] wrote:
Dear colleagues,
If this is not already the case, would you please consider making directed
rounding, as made available on all IEEE 747 compliant processors, simply
accessible to gnuoctave users? This would help assessing the number of
significant digits in the results of floattingpoint computation.
Best regards,
Eric Walter
Dear Eric,
I might not get the point correctly, but are the functions round, fix,
floor, ceil, sign, chop not doing what you need?

Administrator

In reply to this post by Juan Pablo Carbajal2
On 09/17/2015 11:43 AM, Juan Pablo Carbajal wrote:
> On Thu, Sep 17, 2015 at 4:47 PM, Eric Walter
> < [hidden email]> wrote:
>> Dear colleagues,
>>
>> If this is not already the case, would you please consider making directed
>> rounding, as made available on all IEEE 747 compliant processors, simply
>> accessible to gnuoctave users? This would help assessing the number of
>> significant digits in the results of floattingpoint computation.
>>
>> Best regards,
>>
>> Eric Walter
>>
>
> Dear Eric,
>
> I might not get the point correctly, but are the functions round, fix,
> floor, ceil, sign, chop not doing what you need?
Please file a feature request "bug" on the bug tracker.
If I understand correctly, you are asking to make the functions
fegetround and fesetround available in Octave if they are supported by
the system, correct?
It should not be too hard for you to write your own wrappers for those
functions. I'd probably define them to accept/return strings like
"nearest", "up", "down", "towardzero" or similar.
If you do write your own, please consider contributing them.
Thanks,
jwe

Administrator

On 09/17/2015 11:57 AM, John W. Eaton wrote:
> On 09/17/2015 11:43 AM, Juan Pablo Carbajal wrote:
>> On Thu, Sep 17, 2015 at 4:47 PM, Eric Walter
>> < [hidden email]> wrote:
>>> Dear colleagues,
>>>
>>> If this is not already the case, would you please consider making
>>> directed
>>> rounding, as made available on all IEEE 747 compliant processors, simply
>>> accessible to gnuoctave users? This would help assessing the number of
>>> significant digits in the results of floattingpoint computation.
>>>
>>> Best regards,
>>>
>>> Eric Walter
>>>
>>
>> Dear Eric,
>>
>> I might not get the point correctly, but are the functions round, fix,
>> floor, ceil, sign, chop not doing what you need?
>
> Please file a feature request "bug" on the bug tracker.
>
> If I understand correctly, you are asking to make the functions
> fegetround and fesetround available in Octave if they are supported by
> the system, correct?
>
> It should not be too hard for you to write your own wrappers for those
> functions. I'd probably define them to accept/return strings like
> "nearest", "up", "down", "towardzero" or similar.
>
> If you do write your own, please consider contributing them.
>
> Thanks,
>
> jwe
Also, FWIW, the GNU C Library manual has this to say about changing
rounding modes:
You should avoid changing the rounding mode if possible. It can be
an expensive operation; also, some hardware requires you to compile your
program differently for it to work. The resulting code may run slower.
See your compiler documentation for details.
jwe

Administrator

On 09/17/2015 11:56 AM, Eric Walter wrote:
> Dear Juan Pablo,
>
> Thanks for your quick reaction. What I need is a simple way of computing
> the smallest /floatting point number/ that is larger than some given
> real number that may be the result of some computation, as well as the
> largest floatting point number that is smaller that the same real
> number. This corresponds to two of the four rounding modes demanded by
> IEEE 747. As far as I know, none of the functions that you mention
> perform that. MATLAB does not do it, Scilab does not do it either. To
> see how these rounding modes may be used to assess number of significant
> digits, you may consult chapter 14 of the book
>
> http://www.springer.com/fr/book/9783319076706#reviewsSo you are not looking for a function to change the rounding mode, but
you want the nextafter function from glibc?
 Function: double nextafter (double X, double Y)
 Function: float nextafterf (float X, float Y)
 Function: long double nextafterl (long double X, long double Y)
Preliminary:  MTSafe  ASSafe  ACSafe  *Note POSIX Safety
Concepts::.
The 'nextafter' function returns the next representable neighbor of
X in the direction towards Y. The size of the step between X and
the result depends on the type of the result. If X = Y the
function simply returns Y. If either value is 'NaN', 'NaN' is
returned. Otherwise a value corresponding to the value of the
least significant bit in the mantissa is added or subtracted,
depending on the direction. 'nextafter' will signal overflow or
underflow if the result goes outside of the range of normalized
numbers.
This function is defined in IEC 559 (and the appendix with
recommended functions in IEEE 754/IEEE 854).
Or something else? I recommend that you implement this yourself and
contribute it.
It looks to me like a simple twoargument mapper function that could be
handled internally in Octave the same way as atan2, for example.
Thanks,
jwe


Dear John,
Thanks for you quick replies and suggestions. As far as I am able to
judge, you are absolutely right, and what would be needed is a simple
access to fegetround and fesetround. Unfortunately, I will not be able
to make it possible. I was just suggesting that it could be a useful
feature for those who care about the accuracy of their floatting point
computations, and a plus compared to MATLAB ands Scilab, which do not
offer it.
Best regards,
Eric
Le 17/09/2015 17:58, John W. Eaton a écrit :
> On 09/17/2015 11:57 AM, John W. Eaton wrote:
>> On 09/17/2015 11:43 AM, Juan Pablo Carbajal wrote:
>>> On Thu, Sep 17, 2015 at 4:47 PM, Eric Walter
>>> < [hidden email]> wrote:
>>>> Dear colleagues,
>>>>
>>>> If this is not already the case, would you please consider making
>>>> directed
>>>> rounding, as made available on all IEEE 747 compliant processors,
>>>> simply
>>>> accessible to gnuoctave users? This would help assessing the
>>>> number of
>>>> significant digits in the results of floattingpoint computation.
>>>>
>>>> Best regards,
>>>>
>>>> Eric Walter
>>>>
>>>
>>> Dear Eric,
>>>
>>> I might not get the point correctly, but are the functions round, fix,
>>> floor, ceil, sign, chop not doing what you need?
>>
>> Please file a feature request "bug" on the bug tracker.
>>
>> If I understand correctly, you are asking to make the functions
>> fegetround and fesetround available in Octave if they are supported by
>> the system, correct?
>>
>> It should not be too hard for you to write your own wrappers for those
>> functions. I'd probably define them to accept/return strings like
>> "nearest", "up", "down", "towardzero" or similar.
>>
>> If you do write your own, please consider contributing them.
>>
>> Thanks,
>>
>> jwe
>
> Also, FWIW, the GNU C Library manual has this to say about changing
> rounding modes:
>
> You should avoid changing the rounding mode if possible. It can be
> an expensive operation; also, some hardware requires you to compile your
> program differently for it to work. The resulting code may run slower.
> See your compiler documentation for details.
>
> jwe
>


As I told you in my previous email, my goal was just to point out what
would, in my opinion, be a desirable Octave feature. I do not plan to
implement it myself.
Many thanks for the time you took to answer me and for your suggestions.
Many somebody else will feel like doing the job.
Best,
Eric
Le 17/09/2015 18:09, John W. Eaton a écrit :
> On 09/17/2015 11:56 AM, Eric Walter wrote:
>> Dear Juan Pablo,
>>
>> Thanks for your quick reaction. What I need is a simple way of computing
>> the smallest /floatting point number/ that is larger than some given
>> real number that may be the result of some computation, as well as the
>> largest floatting point number that is smaller that the same real
>> number. This corresponds to two of the four rounding modes demanded by
>> IEEE 747. As far as I know, none of the functions that you mention
>> perform that. MATLAB does not do it, Scilab does not do it either. To
>> see how these rounding modes may be used to assess number of significant
>> digits, you may consult chapter 14 of the book
>>
>> http://www.springer.com/fr/book/9783319076706#reviews>
> So you are not looking for a function to change the rounding mode, but
> you want the nextafter function from glibc?
>
>  Function: double nextafter (double X, double Y)
>  Function: float nextafterf (float X, float Y)
>  Function: long double nextafterl (long double X, long double Y)
> Preliminary:  MTSafe  ASSafe  ACSafe  *Note POSIX Safety
> Concepts::.
>
> The 'nextafter' function returns the next representable neighbor of
> X in the direction towards Y. The size of the step between X and
> the result depends on the type of the result. If X = Y the
> function simply returns Y. If either value is 'NaN', 'NaN' is
> returned. Otherwise a value corresponding to the value of the
> least significant bit in the mantissa is added or subtracted,
> depending on the direction. 'nextafter' will signal overflow or
> underflow if the result goes outside of the range of normalized
> numbers.
>
> This function is defined in IEC 559 (and the appendix with
> recommended functions in IEEE 754/IEEE 854).
>
> Or something else? I recommend that you implement this yourself and
> contribute it.
>
> It looks to me like a simple twoargument mapper function that could
> be handled internally in Octave the same way as atan2, for example.
>
> Thanks,
>
> jwe
>
>


On 17.09.2015 18:21, Eric Walter wrote:
> As I told you in my previous email, my goal was just to point out what
> would, in my opinion, be a desirable Octave feature. I do not plan to
> implement it myself.
>
> Many thanks for the time you took to answer me and for your suggestions.
> Many somebody else will feel like doing the job.
>
> Best,
>
> Eric
>
Eric,
you may install the interval package with
octave:1> pkg install forge interval
octave:2> pkg load interval
Then you can access a function called “__setround__”. See “help
__setround__” for instructions.
You might also be interested in the function @infsup/nextout to produce
the next higher and next lower floating point numbers.
http://octave.sourceforge.net/interval/function/@infsup/nextout.htmlBest regards
Oliver


Dear Oliver,
Yes, this might be the way. In MATLAB I got around my rounding problem
by using Sigfried Rump's interval toolbox INTLAB. Many thanks for your
suggestion, and thanks to the Octave community for their amazing reactivity.
Best regards,
Eric
Le 17/09/2015 18:25, Oliver Heimlich a écrit :
> On 17.09.2015 18:21, Eric Walter wrote:
>> As I told you in my previous email, my goal was just to point out what
>> would, in my opinion, be a desirable Octave feature. I do not plan to
>> implement it myself.
>>
>> Many thanks for the time you took to answer me and for your suggestions.
>> Many somebody else will feel like doing the job.
>>
>> Best,
>>
>> Eric
>>
>
> Eric,
>
> you may install the interval package with
>
> octave:1> pkg install forge interval
> octave:2> pkg load interval
>
> Then you can access a function called “__setround__”. See “help
> __setround__” for instructions.
>
> You might also be interested in the function @infsup/nextout to
> produce the next higher and next lower floating point numbers.
>
> http://octave.sourceforge.net/interval/function/@infsup/nextout.html>
> Best regards
> Oliver


On 17.09.2015 18:31, Eric Walter wrote:
> Dear Oliver,
>
> Yes, this might be the way. In MATLAB I got around my rounding problem
> by using Sigfried Rump's interval toolbox INTLAB. Many thanks for your
> suggestion, and thanks to the Octave community for their amazing
> reactivity.
>
> Best regards,
>
> Eric
>
Eric,
you are welcome. Since you know INTLAB, please check whether the free
Octave interval package is a valid replacement for your project. If you
are missing some functionality in the interval package, please let me know.
You can find many functions with directed rounding here (no need to
change the rounding mode yourself):
http://octave.sourceforge.net/interval/function/mpfr_function_d.htmlP.S. The Octave interval package is conforming to the IEEE standard for
interval arithmetic. It might behave differently compared to INTLAB,
especially on empty intervals.
Best regards
Oliver


On 17.09.2015 18:31, Eric Walter wrote: Dear Oliver,
Yes, this might be the way. In MATLAB I got around my rounding problem by using Sigfried Rump's interval toolbox INTLAB. Many thanks for your suggestion, and thanks to the Octave community for their amazing reactivity.
Best regards,
Eric
Eric, you are welcome. Since you know INTLAB, please check whether the free Octave interval package is a valid replacement for your project. If you are missing some functionality in the interval package, please let me know. You can find many functions with directed rounding here (no need to change the rounding mode yourself): http://octave.sourceforge.net/interval/function/mpfr_function_d.htmlP.S. The Octave interval package is conforming to the IEEE standard for interval arithmetic. It might behave differently compared to INTLAB, especially on empty intervals. Best regards Oliver
While most certainly not an Open Source compatible license, INTLAB is open source (small o and s) and free to use excluding only if you are selling a product that uses it. It is free to use, even in commercial setting as long as you aren’t trying to sell a product that includes the code.
As of Octave 3.8, it sounds like INTLAB is fully compatible with Octave.
John S


Dear John,
INTLAB is no longer available for free, although its cost is still
very reasonable. This is no big deal for me as I have access to it
and used it in a project that is now finished, namely the writing of
a chapter devoted to assessing the accuracy of floatting point
computations in a book that has now appeared. I hope many people
will get used to the idea of changing rounding mode to see how
sensitve their computations are.
Best regards,
Eric
Le 17/09/2015 19:05, John Swensen a
écrit :
On 17.09.2015 18:31, Eric Walter wrote:
Dear Oliver,
Yes, this might be the way. In MATLAB I got around my
rounding problem
by using Sigfried Rump's interval toolbox INTLAB. Many
thanks for your
suggestion, and thanks to the Octave community for their
amazing
reactivity.
Best regards,
Eric
Eric,
you are welcome. Since you know INTLAB, please check whether
the free Octave interval package is a valid replacement for
your project. If you are missing some functionality in the
interval package, please let me know.
You can find many functions with directed rounding here (no
need to change the rounding mode yourself):
http://octave.sourceforge.net/interval/function/mpfr_function_d.html
P.S. The Octave interval package is conforming to the IEEE
standard for interval arithmetic. It might behave
differently compared to INTLAB, especially on empty
intervals.
Best regards
Oliver
While most certainly not an Open Source compatible
license, INTLAB is open source (small o and s) and free to use
excluding only if you are selling a product that uses it. It is
free to use, even in commercial setting as long as you aren’t
trying to sell a product that includes the code.
As of Octave 3.8, it sounds like INTLAB is fully
compatible with Octave.
John S

