You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2011/01/21 22:12:06 UTC

[jira] Created: (MATH-493) FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)

FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)
-------------------------------------------------------------------

                 Key: MATH-493
                 URL: https://issues.apache.org/jira/browse/MATH-493
             Project: Commons Math
          Issue Type: Bug
            Reporter: Sebb
             Fix For: 2.2, 3.0


FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):

min(float 0.0, float -0.0) expected -0.0 actual 0.0
min(float Infinity, float -Infinity) expected -Infinity actual NaN
max(float 0.0, float -0.0) expected 0.0 actual -0.0
max(float Infinity, float -Infinity) expected Infinity actual NaN

Similarly for the double versions.

The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

The zero failures are less obvious - they agree with Math, but not with StrictMath.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [Math] FastMath Performance

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
Hello.

> > [...]
> >> Note: this appears to be at least as quick as StrictMath on Sun Java 1.6 in a crude test
> >
> > The performance comparison for "FastMath" should be against "Math", as "StrictMath
> > is expected to be slow(er). [That's why I've added the calls to "Math" in the
> > performance unit tests.]
> 
> The Javadoc for FastMath says that it is a replacement for StrictMath,
> which is why I tested against that.

Unless I'm missing something, this is a doc mistake then. "StrictMath"
results are portable (but possibly not accurate?) but the algorithms are
sometimes "slow". "Math" results possibly change from machine to machine
but the algorithms are expected to sometimes be faster (thanks to hardware
implementations?).

I thought that "FastMath" aimed at better performance than "Math", while
retaining the same (or better) accuracy.

> But it's useful to test against Math as well.

Certainly. E.g. in the code I'm writing, I'm not going to change for
"FastMath" if it is not faster than "Math"!

> Note that a lot of Math methods actually delegate to StrictMath anyway.

I guess that these are the cases where they are sure that they don't loose
efficiency at the expense of reproducibility.

> The main ones that don't are toRadians/toDegrees and min/max.

Any idea why?

> 
> By the way, I got different results in Eclipse and when using Java
> 1.5, so any conclusions we draw from the performance tests need to
> document the conditions.

I think I also noticed constrasting results when changing the number of
runs.


Best,
Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [Math] FastMath Performance (Was: [jira] Resolved: (MATH-493) ...)

Posted by sebb <se...@gmail.com>.
On 24 January 2011 13:11, Gilles Sadowski <gi...@harfang.homelinux.org> wrote:
> Hi.
>
>> Sebb resolved MATH-493.
>> -----------------------
>>
>>     Resolution: Fixed
>>
>> Fixed by using the Harmony code.
>>
>> Note: this appears to be at least as quick as StrictMath on Sun Java 1.6 in a crude test
>
> The performance comparison for "FastMath" should be against "Math", as "StrictMath
> is expected to be slow(er). [That's why I've added the calls to "Math" in the
> performance unit tests.]

The Javadoc for FastMath says that it is a replacement for StrictMath,
which is why I tested against that.

But it's useful to test against Math as well.

Note that a lot of Math methods actually delegate to StrictMath anyway.

The main ones that don't are toRadians/toDegrees and min/max.

By the way, I got different results in Eclipse and when using Java
1.5, so any conclusions we draw from the performance tests need to
document the conditions.

>
> Regards,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[Math] FastMath Performance (Was: [jira] Resolved: (MATH-493) ...)

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
Hi.

> Sebb resolved MATH-493.
> -----------------------
> 
>     Resolution: Fixed
> 
> Fixed by using the Harmony code.
> 
> Note: this appears to be at least as quick as StrictMath on Sun Java 1.6 in a crude test

The performance comparison for "FastMath" should be against "Math", as "StrictMath
is expected to be slow(er). [That's why I've added the calls to "Math" in the
performance unit tests.]


Regards,
Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[jira] Updated: (MATH-493) FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated MATH-493:
----------------------

    Affects Version/s: 3.0
                       2.2

> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)
> -------------------------------------------------------------------
>
>                 Key: MATH-493
>                 URL: https://issues.apache.org/jira/browse/MATH-493
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.2, 3.0
>            Reporter: Sebb
>             Fix For: 2.2, 3.0
>
>
> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):
> min(float 0.0, float -0.0) expected -0.0 actual 0.0
> min(float Infinity, float -Infinity) expected -Infinity actual NaN
> max(float 0.0, float -0.0) expected 0.0 actual -0.0
> max(float Infinity, float -Infinity) expected Infinity actual NaN
> Similarly for the double versions.
> The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Closed] (MATH-493) FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe closed MATH-493.
------------------------------


Closing issue as it was included in version 2.2, which has been released

> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)
> -------------------------------------------------------------------
>
>                 Key: MATH-493
>                 URL: https://issues.apache.org/jira/browse/MATH-493
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.2, 3.0
>            Reporter: Sebb
>             Fix For: 2.2, 3.0
>
>
> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):
> min(float 0.0, float -0.0) expected -0.0 actual 0.0
> min(float Infinity, float -Infinity) expected -Infinity actual NaN
> max(float 0.0, float -0.0) expected 0.0 actual -0.0
> max(float Infinity, float -Infinity) expected Infinity actual NaN
> Similarly for the double versions.
> The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Resolved: (MATH-493) FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved MATH-493.
-----------------------

    Resolution: Fixed

Fixed by using the Harmony code.

Note: this appears to be at least as quick as StrictMath on Sun Java 1.6 in a crude test

> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)
> -------------------------------------------------------------------
>
>                 Key: MATH-493
>                 URL: https://issues.apache.org/jira/browse/MATH-493
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.2, 3.0
>
>
> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):
> min(float 0.0, float -0.0) expected -0.0 actual 0.0
> min(float Infinity, float -Infinity) expected -Infinity actual NaN
> max(float 0.0, float -0.0) expected 0.0 actual -0.0
> max(float Infinity, float -Infinity) expected Infinity actual NaN
> Similarly for the double versions.
> The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MATH-493) FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated MATH-493:
----------------------

    Description: 
FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):

min(float 0.0, float -0.0) expected -0.0 actual 0.0
min(float Infinity, float -Infinity) expected -Infinity actual NaN
max(float 0.0, float -0.0) expected 0.0 actual -0.0
max(float Infinity, float -Infinity) expected Infinity actual NaN

Similarly for the double versions.

The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

  was:
FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):

min(float 0.0, float -0.0) expected -0.0 actual 0.0
min(float Infinity, float -Infinity) expected -Infinity actual NaN
max(float 0.0, float -0.0) expected 0.0 actual -0.0
max(float Infinity, float -Infinity) expected Infinity actual NaN

Similarly for the double versions.

The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

The zero failures are less obvious - they agree with Math, but not with StrictMath.


> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0)
> -------------------------------------------------------------------
>
>                 Key: MATH-493
>                 URL: https://issues.apache.org/jira/browse/MATH-493
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 2.2, 3.0
>
>
> FastMath min and max fail with (Infinity,-Infinity) and (0,0, -0.0):
> min(float 0.0, float -0.0) expected -0.0 actual 0.0
> min(float Infinity, float -Infinity) expected -Infinity actual NaN
> max(float 0.0, float -0.0) expected 0.0 actual -0.0
> max(float Infinity, float -Infinity) expected Infinity actual NaN
> Similarly for the double versions.
> The Infinity failures are because the code uses Float.isNaN(a + b) which gives NaN when +/1- Infinity are added together.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.