commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles Cooper (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-951) Patch: Faster implementation of double org.apache.commons.math3.FastMath.copySign(double, double)
Date Wed, 20 Mar 2013 16:05:15 GMT

    [ https://issues.apache.org/jira/browse/MATH-951?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13607772#comment-13607772
] 

Charles Cooper commented on MATH-951:
-------------------------------------

It's a bitwise XOR. The highest order bit is going to be zero if the highest order bit in
the two numbers is the same, and one if they are different. In other words it's a little like
multiplication (but faster and no overflow) in that the result will be positive if both multiplicands
have the same sign and negative if they have differing sign.
                
> Patch: Faster implementation of double org.apache.commons.math3.FastMath.copySign(double,
double)
> -------------------------------------------------------------------------------------------------
>
>                 Key: MATH-951
>                 URL: https://issues.apache.org/jira/browse/MATH-951
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.2
>         Environment: java version "1.6.0_27"
> OpenJDK Runtime Environment (IcedTea6 1.12.3) (6b27-1.12.3-1)
> OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
> Linux debian 3.2.0-4-amd64 #2 SMP Wed Jan 2 01:41:29 PST 2013 x86_64 GNU/Linux
> Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
>            Reporter: Charles Cooper
>            Priority: Minor
>              Labels: patch, performance
>             Fix For: 3.2
>
>         Attachments: patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> Between 40-50% faster than both current implementation and java.lang.Math.copySign by
my (sloppy) benchmark. Patch attached.

--
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

Mime
View raw message