On 7 September 2011 00:04, Gilles Sadowski <[email protected]> wrote:
> Hello.
>
>> Modified: 
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
>> URL: 
>> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java?rev=1165846&r1=1165845&r2=1165846&view=diff
>> ==============================================================================
>> --- 
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
>>  (original)
>> +++ 
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java
>>  Tue Sep  6 21:06:58 2011
>> @@ -74,31 +74,6147 @@ public class FastMath {
>>      /** Napier's constant e, base of the natural logarithm. */
>>      public static final double E = 2850325.0 / 1048576.0 + 
>> 8.254840070411028747e-8;
>>
>> +    private static final int EXP_INT_TABLE_MAX_INDEX = 750;
>> +    private static final int EXP_INT_TABLE_LEN = EXP_INT_TABLE_MAX_INDEX * 
>> 2;
>> +
>>      /** Exponential evaluated at integer values,
>> -     * exp(x) =  expIntTableA[x + 750] + expIntTableB[x+750].
>> +     * exp(x) =  expIntTableA[x + EXP_INT_TABLE_MAX_INDEX] + 
>> expIntTableB[x+EXP_INT_TABLE_MAX_INDEX].
>>       */
>> -    private static final double EXP_INT_TABLE_A[] = new double[1500];
>> +    private static final double EXP_INT_TABLE_A[] =
>> +    {
>> +        +0.0d,
>> +        Double.NaN,
>
> [More than 6000 lines stripped.]
>
> Wouldn't it be advantageous to store those tabulated data in separate
> Java files? E.g.
> ---
> class ExpIntTables {
>    static final double[] A = {
>      // Very long table.
>    };
>    static final double[] B = {
>      // ...
>    };
> ---
>
> And in "FastMath.java":
> ---
> public class FastMath {
>    private static final double[] EXP_INT_TABLE_A = ExpIntTables.A;
>    private static final double[] EXP_INT_TABLE_B = ExpIntTables.B;
> }
> ---

That would be possible, but would require the tables to be
non-private, increasing the theoretical risk of accidental changes.

>
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to