You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Konstantin Berlin (JIRA)" <ji...@apache.org> on 2012/11/16 18:08:14 UTC

[jira] [Created] (MATH-901) FastMath.sin is slow

Konstantin Berlin created MATH-901:
--------------------------------------

             Summary: FastMath.sin is slow
                 Key: MATH-901
                 URL: https://issues.apache.org/jira/browse/MATH-901
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.1
         Environment: Mac OS 10.8.2, Java 7
            Reporter: Konstantin Berlin


The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.

The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.

Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
JDK Time: 0.698
Apache Time: 0.491
Alternative Time: 0.18

I will add my test code as soon as I figure out how.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498947#comment-13498947 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

I removed their source code. However since its open source you can personally run the tests and look to figure out why it is faster.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (MATH-901) FastMath.sin is slow

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

Konstantin Berlin updated MATH-901:
-----------------------------------

    Attachment: SineTest.java
                FastMath.java

The described FastMath, with some functions removed for simplicity, and my test file.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: FastMath.java, SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498979#comment-13498979 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

I am not suggesting you take their code. I am suggesting we figure what makes their algorithm faster and implement a commons version of it.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501768#comment-13501768 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

I used deliberately the term 'safe' because of the assumption that a more accurate version of any of the provided function should *never* have a negative effect on the outcome / result of programs / algorithms that use them. In fact, the result should improve with more accurate versions.

Do you have something in mind where this assumption breaks?
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499557#comment-13499557 ] 

Gilles commented on MATH-901:
-----------------------------

Can you estimate how much work it would be to port the improvement to "FastMath".

I haven't read the paper, but it seems that the result is "less accurate". Given that the accuracy requirement for "FastMath" is quite stringent, could this code really be used? Or would we have to create "FastAccurateMath" and "VeryFastButNotSoAccurateMath"?

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498986#comment-13498986 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

I could be wrong, but my basic understanding is that the code is protected, not the algorithm. As long as you figure out the algorithm and blindly implement your own version you are not violating LGPL. To protect the algorithm I would image they would need to apply for a patent. 
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498977#comment-13498977 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

As Sebb mentioned, we can not take the code from jafama due to licensing issues (LGPL and Apache licenses are not fully compatible, see http://www.apache.org/licenses/GPL-compatibility.html especially paragraph 3).
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498967#comment-13498967 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

The difference in accuracy is very close to machine precision. I would image for 99% of applications, people would prefer 3x speedup rather than the accuracy. In any case there should be a choice to select what you want.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501444#comment-13501444 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

Hi Jeff,

thanks for your feedback, I will create bug reports for the issues you reported.

I am also +1 on having an AccurateMath and a FastMath implementation with the following characteristics:

 * AccurateMath: being more accurate, and faster *if* possible than Math (more or less the current FastMath)
 * FastMath: being (considerably) faster with tradeoffs for accuracy (more or less the jodk FastMath)

What would be an acceptable loss of accuracy, opinions?

If we decide to do something like this, we should also add a specific page in the user guide, describing the differences with figures for performance and accuracy. Right now, FastMath is advertised as safe drop-in replacement to Math, but with two diverting implementations with different goals, users would need more guidance I guess.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499546#comment-13499546 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

Good news the library is now apache 2.0 
And can be found here
http://code.google.com/p/jodk/

I think the code can be easily integrated
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498996#comment-13498996 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

>From my quick scan of the code it seem to be based off plain polynomial approximations, with some reordering to decrease floating point errors. A quick search for a paper yields this
http://www.krisgarrett.net/papers/l2approx.pdf


                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501578#comment-13501578 ] 

Jeff Hain commented on MATH-901:
--------------------------------

>What would be an acceptable loss of accuracy, opinions?

If the user doesn't need correct rounding and monotonicity
subtleties, I think an acceptable loss should be about
1e-15, i.e. about the precision of doubles, so that there
is not much visible loss for a few lucky computations.
In jodk, tan/exp/pow accuracy can be as bad as about 1e-12,
but that's for relatively large values, and that's fine
since the user is (or should be!) aware that he's using
something designed to be fast more than accurate.

>If we decide to do something like this, we should also
>add a specific page in the user guide, describing the
>differences with figures for performance and accuracy.
>Right now, FastMath is advertised as safe drop-in replacement
>to Math, but with two diverting implementations with different
>goals, users would need more guidance I guess.

For a drop-in replacement to be really safe, it needs to
behave exactly (except for speed) like the original, but
current FastMath claims to be more accurate so it can't be
one.

The JDK already has two Math classes (Math and StrictMath).
If you do a faster and safe drop-in replacement for one of these,
ideally you should try to get it into JDK since it's now open,
to avoid people ending up with too many implementations around
(I don't think it's worth it to have yet another class, just to
end up with similar accuracy and speed, especially for such low-level
features).
Some people at Sun/Oracle already thought about faster and
pure java implementations, see mails at
http://www.mail-archive.com/core-libs-dev@openjdk.java.net/msg03359.html

-Jeff

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (MATH-901) FastMath.sin is slow

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

Konstantin Berlin updated MATH-901:
-----------------------------------

    Attachment:     (was: FastMath.java)
    
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (MATH-901) FastMath.sin is slow

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501578#comment-13501578 ] 

Jeff Hain edited comment on MATH-901 at 11/20/12 11:28 PM:
-----------------------------------------------------------

>What would be an acceptable loss of accuracy, opinions?

If the user doesn't need correct rounding and monotonicity
subtleties, I think an acceptable loss should be about
1e-15, i.e. about the precision of doubles, so that there
is not much visible loss for a few lucky computations.
In jodk, tan/exp/pow accuracy can be as bad as about 1e-12,
but that's for relatively large/small values, and that's fine
since the user is (or should be!) aware that he's using
something designed to be fast more than accurate.

>If we decide to do something like this, we should also
>add a specific page in the user guide, describing the
>differences with figures for performance and accuracy.
>Right now, FastMath is advertised as safe drop-in replacement
>to Math, but with two diverting implementations with different
>goals, users would need more guidance I guess.

For a drop-in replacement to be really safe, it needs to
behave exactly (except for speed) like the original, but
current FastMath claims to be more accurate so it can't be
one.

The JDK already has two Math classes (Math and StrictMath).
If you do a faster and safe drop-in replacement for one of these,
ideally you should try to get it into JDK since it's now open,
to avoid people ending up with too many implementations around
(I don't think it's worth it to have yet another class, just to
end up with similar accuracy and speed, especially for such low-level
features).
Some people at Sun/Oracle already thought about faster and
pure java implementations, see mails at
http://www.mail-archive.com/core-libs-dev@openjdk.java.net/msg03359.html

-Jeff

                
      was (Author: jeff):
    >What would be an acceptable loss of accuracy, opinions?

If the user doesn't need correct rounding and monotonicity
subtleties, I think an acceptable loss should be about
1e-15, i.e. about the precision of doubles, so that there
is not much visible loss for a few lucky computations.
In jodk, tan/exp/pow accuracy can be as bad as about 1e-12,
but that's for relatively large values, and that's fine
since the user is (or should be!) aware that he's using
something designed to be fast more than accurate.

>If we decide to do something like this, we should also
>add a specific page in the user guide, describing the
>differences with figures for performance and accuracy.
>Right now, FastMath is advertised as safe drop-in replacement
>to Math, but with two diverting implementations with different
>goals, users would need more guidance I guess.

For a drop-in replacement to be really safe, it needs to
behave exactly (except for speed) like the original, but
current FastMath claims to be more accurate so it can't be
one.

The JDK already has two Math classes (Math and StrictMath).
If you do a faster and safe drop-in replacement for one of these,
ideally you should try to get it into JDK since it's now open,
to avoid people ending up with too many implementations around
(I don't think it's worth it to have yet another class, just to
end up with similar accuracy and speed, especially for such low-level
features).
Some people at Sun/Oracle already thought about faster and
pure java implementations, see mails at
http://www.mail-archive.com/core-libs-dev@openjdk.java.net/msg03359.html

-Jeff

                  
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498981#comment-13498981 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

If you have a paper describing the basic principle we can do that.
Looking at the code and re-implementing it would be problematic imho.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499000#comment-13499000 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

This is very useful indeed, thanks!
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499552#comment-13499552 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

I did some more tests with jodk and they look very promising, e.g. log and log10 are *much* faster than the current implementation in commons-math (which is known to be slow, see also http://blog.juma.me.uk/2011/02/23/performance-of-fastmath-from-commons-math/).
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (MATH-901) FastMath.sin is slow

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

Thomas Neidhart updated MATH-901:
---------------------------------

    Issue Type: Sub-task  (was: Bug)
        Parent: MATH-740
    
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499562#comment-13499562 ] 

Gilles commented on MATH-901:
-----------------------------

bq. Maybe we should contact him and ask him if he is willing to contribute to commons-math in general

That would be great.



                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498961#comment-13498961 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

Converted to a sub-task for MATH-740.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501394#comment-13501394 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

I have an program where I do an all-to-all summation of the sinc function of thousands of objects. Though an FMM or GPU code would work better, but might be difficult for users to implement.

It's called the Debye formula for small angle scattering (SAXS, SANS).
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

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

Sebb commented on MATH-901:
---------------------------

The code at [1] is LGPL, so AFAIK cannot be included as source.

Attaching the code to this JIRA issue seems wrong - as far as I can tell it is not your code.
Please remove the attachment FastMath.java.
Thanks.

[1]  http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: FastMath.java, SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Konstantin Berlin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498992#comment-13498992 ] 

Konstantin Berlin commented on MATH-901:
----------------------------------------

Also looks like their implementation is based off 
http://www.netlib.org/fdlibm/

which has no limitations in the license. 
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501567#comment-13501567 ] 

Gilles commented on MATH-901:
-----------------------------

bq. I have an program where I do an all-to-all summation of the sinc function of thousands of objects. [...]

Is it possible (and would you be willing) to adapt it for inclusion in CM, as a "performance" test?

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501191#comment-13501191 ] 

Gilles commented on MATH-901:
-----------------------------

{quote}
commons-math:
[...]
* no big tables (it seems)
{quote}

Tables are used by "FastMath" ("FastMathLiteralArrays").

bq. So it's normal you can't just replace one with another

Ideally, that should be feasible; especially useful if the trade-off is large and some applications have different requirements (speed vs accuracy).

Someone should definitely put forward some real-life benchmarks (or application) that show significant speed differences, as we already had heated discussions for what I considered an utterly insignificant speed gain (a few milliseconds over an application's whole life)...

{quote}
Meanwhile, there are a few methods from JODK's FastMath
that might fulfill commons-math requirements, and be faster, [...]
{quote}

That would be really nice.
Could you provide a patch?

bq.  several methods are noticeably slower, like log/log10/log1p/atan/atan2

Yes, that was already noticed (MATH-740).

bq. for some values all hell breaks loose:

We should definitely track these bugs in their own tickets. Thanks!

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502203#comment-13502203 ] 

Jeff Hain commented on MATH-901:
--------------------------------

>Do you have something in mind where this assumption breaks?

I just said that because I'm picky :)

I agree that if it has the same spec than Math,
i.e. allows for some slight variations on the result,
the replacement should be safe.

But I wouldn't speak about safety, I would just say that
it has similar (or better) accuracy, which would warn
the user that the result might be different.
You never know what false assumptions people do when
they build software, and some people might have
used Math, and now use FastMath, in place where they
should rather have used StrictMath (for example if
needing result consistency across versions of their
software, to allow for comparisons with past results,
or if they use doubles as keys, etc.).

-Jeff

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499558#comment-13499558 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

The author of the library (Jeff Hain), also proposed some of the features (ceil, floor) to the openjdk project (see http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-January/003522.html), where he also explains the relationship between jafama and jodk. Maybe we should contact him and ask him if he is willing to contribute to commons-math in general?
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499563#comment-13499563 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

hmm, the maximum error is quite large for some functions, compared to the current implementations:

 * sin: -1063.167 ULP
 * cos: 971 ULP
 * log: 1.19 ULP
 * log10: 3.46 ULP
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Jeff Hain (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501390#comment-13501390 ] 

Jeff Hain commented on MATH-901:
--------------------------------


>>So it's normal you can't just replace one with another
>
>Ideally, that should be feasible; especially useful if
>the trade-off is large and some applications have different
>requirements (speed vs accuracy).

All depends on what you want FastMath to be.
Up to you.



>Someone should definitely put forward some real-life benchmarks
>(or application) that show significant speed differences, as we
>already had heated discussions for what I considered an utterly
>insignificant speed gain (a few milliseconds over an application's
>whole life)...

In practice you only see improvements for applications doing
intensive math computations.
The only "real-life" example I had was for a 3D GUI displaying
tens of thousands of mobile objects, geographically located,
using various kinds of Earth models (ellipsoids) and projections
(like transverse mercator), and with a screen update every 100ms.
That was like 300000 objects drawings per second, each involving
multiple trigonometric computations, let say 10, so 3 millions
trigonometric computations per second (and no parallelization,
even though the problem is embarrassingly parallel).
===> With FastMath it was smoother.



>>Meanwhile, there are a few methods from JODK's FastMath
>>that might fulfill commons-math requirements, and be faster, [...]
>
>That would be really nice.
>Could you provide a patch?

I prefer let you or another usual contributor take care of that
(and all eventual related implications, choices, details, etc.).
I'm more or less busy on something and prefer not to start get
involved somewhere else, other than mails from time to time.



-Jeff

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (MATH-901) FastMath.sin is slow

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

Gilles updated MATH-901:
------------------------

    Affects Version/s:     (was: 3.1)
                       3.0
    
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13499570#comment-13499570 ] 

Gilles commented on MATH-901:
-----------------------------

So, ruled out for "FastMath"?

Providing a separate "VeryFastNotAccurateMath" based on that code could be a new, independent, feature.

                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.0
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (MATH-901) FastMath.sin is slow

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13498964#comment-13498964 ] 

Thomas Neidhart commented on MATH-901:
--------------------------------------

One of the reasons this variant is faster is because it is less accurate, which may not be acceptable for commons-math.
                
> FastMath.sin is slow
> --------------------
>
>                 Key: MATH-901
>                 URL: https://issues.apache.org/jira/browse/MATH-901
>             Project: Commons Math
>          Issue Type: Sub-task
>    Affects Versions: 3.1
>         Environment: Mac OS 10.8.2, Java 7
>            Reporter: Konstantin Berlin
>         Attachments: SineTest.java
>
>
> The FastMath.sin (maybe other functions too) are not nearly as fast as some other libraries that can be found on the internet.
> The *much* faster code can be found here http://www.oliford.co.uk/phys/code/AlgorithmRepository/src/jafama/.
> Max Absolute Error Apache vs JDK: 1.1102230246251565E-16
> Max Absolute Error Alternative vs JDK: 5.551115123125783E-16
> JDK Time: 0.698
> Apache Time: 0.491
> Alternative Time: 0.18
> I will add my test code as soon as I figure out how.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira