You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Luc Maisonobe (JIRA)" <ji...@apache.org> on 2013/03/25 11:53:15 UTC

[jira] [Resolved] (MATH-954) Faster implementation of FastMath.abs

     [ https://issues.apache.org/jira/browse/MATH-954?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe resolved MATH-954.
--------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 3.1.1)
                   3.2

Fixed in subversion repository as of r1460604.

Patch applied with minor formatting changes (no tabs, curly braces and single line if).

I wonder if it would be possible to use the same bits twiddling tricks for the float/double once converted to int/long, and converting back? If this worked, it would also remove the remaining if.

Luc
                
> Faster implementation of FastMath.abs
> -------------------------------------
>
>                 Key: MATH-954
>                 URL: https://issues.apache.org/jira/browse/MATH-954
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.1.1
>         Environment: java version "1.6.0_27"
> OpenJDK Runtime Environment (IcedTea6 1.12.4) (6b27-1.12.4-1)
> OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
> Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.39-2 x86_64 GNU/Linux
> Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
>            Reporter: Charles Cooper
>            Priority: Minor
>              Labels: optimization, patch
>             Fix For: 3.2
>
>         Attachments: patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> Faster implementations of abs() which use bitwise operations in preference to branching. By my benchmark abs(double/float) are about 10-20% faster, and abs(long/int) more than twice as fast. 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