You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Phil Steitz <ph...@gmail.com> on 2014/03/25 18:28:14 UTC
Re: svn commit: r1581383 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
I am OK with this but curious if it in fact makes any difference.
Anyone know?
Phil
On 3/25/14, 8:51 AM, erans@apache.org wrote:
> Author: erans
> Date: Tue Mar 25 15:51:25 2014
> New Revision: 1581383
>
> URL: http://svn.apache.org/r1581383
> Log:
> Minimize number of array accesses.
>
> Modified:
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
>
> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java?rev=1581383&r1=1581382&r2=1581383&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java (original)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java Tue Mar 25 15:51:25 2014
> @@ -2457,9 +2457,13 @@ public class FastMath {
> final double oneOverXa = 1 / xa;
> idx = (int) (-((-1.7168146928204136 * oneOverXa * oneOverXa + 8.0) * oneOverXa) + 13.07);
> }
> - double epsA = xa - TANGENT_TABLE_A[idx];
> - double epsB = -(epsA - xa + TANGENT_TABLE_A[idx]);
> - epsB += xb - TANGENT_TABLE_B[idx];
> +
> + final double ttA = TANGENT_TABLE_A[idx];
> + final double ttB = TANGENT_TABLE_B[idx];
> +
> + double epsA = xa - ttA;
> + double epsB = -(epsA - xa + ttA);
> + epsB += xb - ttB;
>
> double temp = epsA + epsB;
> epsB = -(temp - epsA - epsB);
> @@ -2476,20 +2480,20 @@ public class FastMath {
> if (idx == 0) {
> /* If the slope of the arctan is gentle enough (< 0.45), this approximation will suffice */
> //double denom = 1.0 / (1.0 + xa*tangentTableA[idx] + xb*tangentTableA[idx] + xa*tangentTableB[idx] + xb*tangentTableB[idx]);
> - final double denom = 1d / (1d + (xa + xb) * (TANGENT_TABLE_A[idx] + TANGENT_TABLE_B[idx]));
> + final double denom = 1d / (1d + (xa + xb) * (ttA + ttB));
> //double denom = 1.0 / (1.0 + xa*tangentTableA[idx]);
> ya = epsA * denom;
> yb = epsB * denom;
> } else {
> - double temp2 = xa * TANGENT_TABLE_A[idx];
> + double temp2 = xa * ttA;
> double za = 1d + temp2;
> double zb = -(za - 1d - temp2);
> - temp2 = xb * TANGENT_TABLE_A[idx] + xa * TANGENT_TABLE_B[idx];
> + temp2 = xb * ttA + xa * ttB;
> temp = za + temp2;
> zb += -(temp - za - temp2);
> za = temp;
>
> - zb += xb * TANGENT_TABLE_B[idx];
> + zb += xb * ttB;
> ya = epsA / za;
>
> temp = ya * HEX_40000000;
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org