You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2010/08/30 00:04:15 UTC
svn commit: r990658 [1/10] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/analysis/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/analysis/interpolation/
src/main/java/org/a...
Author: luc
Date: Sun Aug 29 22:04:09 2010
New Revision: 990658
URL: http://svn.apache.org/viewvc?rev=990658&view=rev
Log:
added FastMath and used it everywhere in replacement of java.util.Math
the unit tests have not been added yet (waiting for dfp library addition)
JIRA: MATH-375
Added:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/FastMath.java (with props)
Modified:
commons/proper/math/trunk/findbugs-exclude-filter.xml
commons/proper/math/trunk/pom.xml
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/BinaryFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/ComposableFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/ComplexUtils.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/SaddlePointExpansion.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/AbstractEstimator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/BigFraction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/fraction/Fraction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/genetics/ElitisticListPopulation.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/Rotation.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/geometry/Vector3D.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealVector.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/ArrayRealVector.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BiDiagonalTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockFieldMatrix.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockRealMatrix.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/ContinuousOutputModel.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/MultistepIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/events/EventState.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/HighamHall54Integrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/NordsieckStepInterpolator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleRealPointChecker.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleScalarValueChecker.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleVectorialPointChecker.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleVectorialValueChecker.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicCoefficientsGuesser.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFitter.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/fitting/HarmonicFunction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/BaseAbstractScalarOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/NonLinearConjugateGradientOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/AbstractRandomGenerator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/BitsStreamGenerator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/MersenneTwister.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/UniformRandomGenerator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/UnitSphereRandomVectorGenerator.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Beta.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/special/Gamma.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Product.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/TTestImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/NaturalRanking.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ContinuedFraction.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToDoubleHashMap.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/OpenIntToFieldHashMap.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ResizableDoubleArray.java
commons/proper/math/trunk/src/site/xdoc/changes.xml
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ArgumentOutsideDomainExceptionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/BinaryFunctionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/ComposableFunctionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/Expm1Function.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/SinFunction.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/integration/RombergIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/integration/SimpsonIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/integration/TrapezoidIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/DividedDifferenceInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/NevilleInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/SmoothingPolynomialBicubicSplineInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/SplineInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatingFunctionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/TricubicSplineInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtilsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BisectionSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/BrentSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/LaguerreSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/MullerSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/NewtonSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/RiddersSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtilsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexFormatAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/complex/ComplexUtilsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/EstimatedParameterTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/MinpackTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/WeightedMeasurementTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionFormatTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/genetics/GeneticAlgorithmTestPermutations.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/RotationTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/Vector3DTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/Array2DRowRealMatrixTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/ArrayRealVectorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BiDiagonalTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem1.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem2.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem3.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblem4.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/TestProblemHandler.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/jacobians/FirstOrderIntegratorWithJacobiansTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepInterpolatorTestUtils.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/MinpackTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/univariate/BrentOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/MersenneTwisterTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/special/ErfTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/special/GammaTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/StatUtilsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/clustering/EuclideanIntegerPointTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatisticsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/UnivariateStatisticAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviationTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastCosineTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastFourierTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/transform/FastSineTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/BigRealTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java
Modified: commons/proper/math/trunk/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/findbugs-exclude-filter.xml?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/math/trunk/findbugs-exclude-filter.xml Sun Aug 29 22:04:09 2010
@@ -83,6 +83,13 @@
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
</Match>
+ <!-- The following equality test is intentional for infinity detection -->
+ <Match>
+ <Class name="org.apache.commons.math.util.FastMath" />
+ <Method name="atan2" params="double,double" returns="double" />
+ <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
+ </Match>
+
<!-- the following expositions of internal representation are intentional and documented -->
<Match>
Modified: commons/proper/math/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/pom.xml?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/pom.xml (original)
+++ commons/proper/math/trunk/pom.xml Sun Aug 29 22:04:09 2010
@@ -197,6 +197,9 @@
<name>Andreas Rieger</name>
</contributor>
<contributor>
+ <name>Bill Rossi</name>
+ </contributor>
+ <contributor>
<name>Matthew Rowles</name>
</contributor>
<contributor>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/BinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/BinaryFunction.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/BinaryFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/BinaryFunction.java Sun Aug 29 22:04:09 2010
@@ -18,6 +18,7 @@
package org.apache.commons.math.analysis;
import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.util.FastMath;
@@ -65,21 +66,21 @@ public abstract class BinaryFunction imp
}
};
- /** The {@code Math.pow} method wrapped as a {@link BinaryFunction}. */
+ /** The {@code FastMath.pow} method wrapped as a {@link BinaryFunction}. */
public static final BinaryFunction POW = new BinaryFunction() {
/** {@inheritDoc} */
@Override
public double value(double x, double y) {
- return Math.pow(x, y);
+ return FastMath.pow(x, y);
}
};
- /** The {@code Math.atan2} method wrapped as a {@link BinaryFunction}. */
+ /** The {@code FastMath.atan2} method wrapped as a {@link BinaryFunction}. */
public static final BinaryFunction ATAN2 = new BinaryFunction() {
/** {@inheritDoc} */
@Override
public double value(double x, double y) {
- return Math.atan2(x, y);
+ return FastMath.atan2(x, y);
}
};
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/ComposableFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/ComposableFunction.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/ComposableFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/ComposableFunction.java Sun Aug 29 22:04:09 2010
@@ -18,6 +18,7 @@
package org.apache.commons.math.analysis;
import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.util.FastMath;
/**
@@ -55,12 +56,12 @@ public abstract class ComposableFunction
}
};
- /** The {@code Math.abs} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.abs} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction ABS = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.abs(d);
+ return FastMath.abs(d);
}
};
@@ -82,191 +83,191 @@ public abstract class ComposableFunction
}
};
- /** The {@code Math.sin} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.sin} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction SIN = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.sin(d);
+ return FastMath.sin(d);
}
};
- /** The {@code Math.sqrt} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.sqrt} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction SQRT = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.sqrt(d);
+ return FastMath.sqrt(d);
}
};
- /** The {@code Math.sinh} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.sinh} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction SINH = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.sinh(d);
+ return FastMath.sinh(d);
}
};
- /** The {@code Math.exp} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.exp} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction EXP = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.exp(d);
+ return FastMath.exp(d);
}
};
- /** The {@code Math.expm1} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.expm1} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction EXPM1 = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.expm1(d);
+ return FastMath.expm1(d);
}
};
- /** The {@code Math.asin} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.asin} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction ASIN = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.asin(d);
+ return FastMath.asin(d);
}
};
- /** The {@code Math.atan} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.atan} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction ATAN = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.atan(d);
+ return FastMath.atan(d);
}
};
- /** The {@code Math.tan} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.tan} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction TAN = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.tan(d);
+ return FastMath.tan(d);
}
};
- /** The {@code Math.tanh} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.tanh} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction TANH = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.tanh(d);
+ return FastMath.tanh(d);
}
};
- /** The {@code Math.cbrt} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.cbrt} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction CBRT = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.cbrt(d);
+ return FastMath.cbrt(d);
}
};
- /** The {@code Math.ceil} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.ceil} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction CEIL = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.ceil(d);
+ return FastMath.ceil(d);
}
};
- /** The {@code Math.floor} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.floor} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction FLOOR = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.floor(d);
+ return FastMath.floor(d);
}
};
- /** The {@code Math.log} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.log} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction LOG = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.log(d);
+ return FastMath.log(d);
}
};
- /** The {@code Math.log10} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.log10} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction LOG10 = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.log10(d);
+ return FastMath.log10(d);
}
};
- /** The {@code Math.log1p} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.log1p} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction LOG1P = new ComposableFunction () {
@Override
public double value(double d){
- return Math.log1p(d);
+ return FastMath.log1p(d);
}
};
- /** The {@code Math.cos} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.cos} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction COS = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.cos(d);
+ return FastMath.cos(d);
}
};
- /** The {@code Math.abs} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.abs} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction ACOS = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.acos(d);
+ return FastMath.acos(d);
}
};
- /** The {@code Math.cosh} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.cosh} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction COSH = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.cosh(d);
+ return FastMath.cosh(d);
}
};
- /** The {@code Math.rint} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.rint} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction RINT = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.rint(d);
+ return FastMath.rint(d);
}
};
- /** The {@code Math.signum} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.signum} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction SIGNUM = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.signum(d);
+ return FastMath.signum(d);
}
};
- /** The {@code Math.ulp} method wrapped as a {@link ComposableFunction}. */
+ /** The {@code FastMath.ulp} method wrapped as a {@link ComposableFunction}. */
public static final ComposableFunction ULP = new ComposableFunction() {
/** {@inheritDoc} */
@Override
public double value(double d) {
- return Math.ulp(d);
+ return FastMath.ulp(d);
}
};
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java Sun Aug 29 22:04:09 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/Legendre-GaussQuadrature.html">
@@ -54,8 +55,8 @@ public class LegendreGaussIntegrator ext
/** Abscissas for the 2 points method. */
private static final double[] ABSCISSAS_2 = {
- -1.0 / Math.sqrt(3.0),
- 1.0 / Math.sqrt(3.0)
+ -1.0 / FastMath.sqrt(3.0),
+ 1.0 / FastMath.sqrt(3.0)
};
/** Weights for the 2 points method. */
@@ -66,9 +67,9 @@ public class LegendreGaussIntegrator ext
/** Abscissas for the 3 points method. */
private static final double[] ABSCISSAS_3 = {
- -Math.sqrt(0.6),
+ -FastMath.sqrt(0.6),
0.0,
- Math.sqrt(0.6)
+ FastMath.sqrt(0.6)
};
/** Weights for the 3 points method. */
@@ -80,36 +81,36 @@ public class LegendreGaussIntegrator ext
/** Abscissas for the 4 points method. */
private static final double[] ABSCISSAS_4 = {
- -Math.sqrt((15.0 + 2.0 * Math.sqrt(30.0)) / 35.0),
- -Math.sqrt((15.0 - 2.0 * Math.sqrt(30.0)) / 35.0),
- Math.sqrt((15.0 - 2.0 * Math.sqrt(30.0)) / 35.0),
- Math.sqrt((15.0 + 2.0 * Math.sqrt(30.0)) / 35.0)
+ -FastMath.sqrt((15.0 + 2.0 * FastMath.sqrt(30.0)) / 35.0),
+ -FastMath.sqrt((15.0 - 2.0 * FastMath.sqrt(30.0)) / 35.0),
+ FastMath.sqrt((15.0 - 2.0 * FastMath.sqrt(30.0)) / 35.0),
+ FastMath.sqrt((15.0 + 2.0 * FastMath.sqrt(30.0)) / 35.0)
};
/** Weights for the 4 points method. */
private static final double[] WEIGHTS_4 = {
- (90.0 - 5.0 * Math.sqrt(30.0)) / 180.0,
- (90.0 + 5.0 * Math.sqrt(30.0)) / 180.0,
- (90.0 + 5.0 * Math.sqrt(30.0)) / 180.0,
- (90.0 - 5.0 * Math.sqrt(30.0)) / 180.0
+ (90.0 - 5.0 * FastMath.sqrt(30.0)) / 180.0,
+ (90.0 + 5.0 * FastMath.sqrt(30.0)) / 180.0,
+ (90.0 + 5.0 * FastMath.sqrt(30.0)) / 180.0,
+ (90.0 - 5.0 * FastMath.sqrt(30.0)) / 180.0
};
/** Abscissas for the 5 points method. */
private static final double[] ABSCISSAS_5 = {
- -Math.sqrt((35.0 + 2.0 * Math.sqrt(70.0)) / 63.0),
- -Math.sqrt((35.0 - 2.0 * Math.sqrt(70.0)) / 63.0),
+ -FastMath.sqrt((35.0 + 2.0 * FastMath.sqrt(70.0)) / 63.0),
+ -FastMath.sqrt((35.0 - 2.0 * FastMath.sqrt(70.0)) / 63.0),
0.0,
- Math.sqrt((35.0 - 2.0 * Math.sqrt(70.0)) / 63.0),
- Math.sqrt((35.0 + 2.0 * Math.sqrt(70.0)) / 63.0)
+ FastMath.sqrt((35.0 - 2.0 * FastMath.sqrt(70.0)) / 63.0),
+ FastMath.sqrt((35.0 + 2.0 * FastMath.sqrt(70.0)) / 63.0)
};
/** Weights for the 5 points method. */
private static final double[] WEIGHTS_5 = {
- (322.0 - 13.0 * Math.sqrt(70.0)) / 900.0,
- (322.0 + 13.0 * Math.sqrt(70.0)) / 900.0,
+ (322.0 - 13.0 * FastMath.sqrt(70.0)) / 900.0,
+ (322.0 + 13.0 * FastMath.sqrt(70.0)) / 900.0,
128.0 / 225.0,
- (322.0 + 13.0 * Math.sqrt(70.0)) / 900.0,
- (322.0 - 13.0 * Math.sqrt(70.0)) / 900.0
+ (322.0 + 13.0 * FastMath.sqrt(70.0)) / 900.0,
+ (322.0 - 13.0 * FastMath.sqrt(70.0)) / 900.0
};
/** Abscissas for the current method. */
@@ -178,10 +179,10 @@ public class LegendreGaussIntegrator ext
final double t = stage(f, min, max, n);
// estimate error
- final double delta = Math.abs(t - oldt);
+ final double delta = FastMath.abs(t - oldt);
final double limit =
- Math.max(absoluteAccuracy,
- relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5);
+ FastMath.max(absoluteAccuracy,
+ relativeAccuracy * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5);
// check convergence
if ((i + 1 >= minimalIterationCount) && (delta <= limit)) {
@@ -190,8 +191,8 @@ public class LegendreGaussIntegrator ext
}
// prepare next iteration
- double ratio = Math.min(4, Math.pow(delta / limit, 0.5 / abscissas.length));
- n = Math.max((int) (ratio * n), n + 1);
+ double ratio = FastMath.min(4, FastMath.pow(delta / limit, 0.5 / abscissas.length));
+ n = FastMath.max((int) (ratio * n), n + 1);
oldt = t;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/RombergIntegrator.java Sun Aug 29 22:04:09 2010
@@ -21,6 +21,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/RombergIntegration.html">
@@ -95,8 +96,8 @@ public class RombergIntegrator extends U
}
final double s = currentRow[i];
if (i >= minimalIterationCount) {
- final double delta = Math.abs(s - olds);
- final double rLimit = relativeAccuracy * (Math.abs(olds) + Math.abs(s)) * 0.5;
+ final double delta = FastMath.abs(s - olds);
+ final double rLimit = relativeAccuracy * (FastMath.abs(olds) + FastMath.abs(s)) * 0.5;
if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
setResult(s, i);
return result;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/SimpsonIntegrator.java Sun Aug 29 22:04:09 2010
@@ -21,6 +21,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/SimpsonsRule.html">
@@ -84,9 +85,9 @@ public class SimpsonIntegrator extends U
final double t = qtrap.stage(f, min, max, i);
final double s = (4 * t - oldt) / 3.0;
if (i >= minimalIterationCount) {
- final double delta = Math.abs(s - olds);
+ final double delta = FastMath.abs(s - olds);
final double rLimit =
- relativeAccuracy * (Math.abs(olds) + Math.abs(s)) * 0.5;
+ relativeAccuracy * (FastMath.abs(olds) + FastMath.abs(s)) * 0.5;
if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
setResult(s, i);
return result;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/integration/TrapezoidIntegrator.java Sun Aug 29 22:04:09 2010
@@ -21,6 +21,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/TrapezoidalRule.html">
@@ -116,9 +117,9 @@ public class TrapezoidIntegrator extends
for (int i = 1; i <= maximalIterationCount; ++i) {
final double t = stage(f, min, max, i);
if (i >= minimalIterationCount) {
- final double delta = Math.abs(t - oldt);
+ final double delta = FastMath.abs(t - oldt);
final double rLimit =
- relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
+ relativeAccuracy * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5;
if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
setResult(t, i);
return result;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/LoessInterpolator.java Sun Aug 29 22:04:09 2010
@@ -23,6 +23,7 @@ import org.apache.commons.math.MathExcep
import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.math.exception.util.Localizable;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://en.wikipedia.org/wiki/Local_regression">
@@ -277,7 +278,7 @@ public class LoessInterpolator
double sumXSquared = 0;
double sumY = 0;
double sumXY = 0;
- double denom = Math.abs(1.0 / (xval[edge] - x));
+ double denom = FastMath.abs(1.0 / (xval[edge] - x));
for (int k = ileft; k <= iright; ++k) {
final double xk = xval[k];
final double yk = yval[k];
@@ -297,7 +298,7 @@ public class LoessInterpolator
final double meanXSquared = sumXSquared / sumWeights;
final double beta;
- if (Math.sqrt(Math.abs(meanXSquared - meanX * meanX)) < accuracy) {
+ if (FastMath.sqrt(FastMath.abs(meanXSquared - meanX * meanX)) < accuracy) {
beta = 0;
} else {
beta = (meanXY - meanX * meanY) / (meanXSquared - meanX * meanX);
@@ -306,7 +307,7 @@ public class LoessInterpolator
final double alpha = meanY - beta * meanX;
res[i] = beta * x + alpha;
- residuals[i] = Math.abs(yval[i] - res[i]);
+ residuals[i] = FastMath.abs(yval[i] - res[i]);
}
// No need to recompute the robustness weights at the last
@@ -324,7 +325,7 @@ public class LoessInterpolator
Arrays.sort(sortedResiduals);
final double medianResidual = sortedResiduals[n / 2];
- if (Math.abs(medianResidual) < accuracy) {
+ if (FastMath.abs(medianResidual) < accuracy) {
break;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/interpolation/MicrosphereInterpolatingFunction.java Sun Aug 29 22:04:09 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.exception
import org.apache.commons.math.linear.ArrayRealVector;
import org.apache.commons.math.linear.RealVector;
import org.apache.commons.math.random.UnitSphereRandomVectorGenerator;
+import org.apache.commons.math.util.FastMath;
/**
* Interpolating function that implements the
@@ -200,14 +201,14 @@ public class MicrosphereInterpolatingFun
final RealVector diff = sd.getKey().subtract(p);
final double diffNorm = diff.getNorm();
- if (Math.abs(diffNorm) < Math.ulp(1d)) {
+ if (FastMath.abs(diffNorm) < FastMath.ulp(1d)) {
// No need to interpolate, as the interpolation point is
// actually (very close to) one of the sampled points.
return sd.getValue();
}
for (MicrosphereSurfaceElement md : microsphere) {
- final double w = Math.pow(diffNorm, -brightnessExponent);
+ final double w = FastMath.pow(diffNorm, -brightnessExponent);
md.store(cosAngle(diff, md.normal()) * w, sd);
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java Sun Aug 29 22:04:09 2010
@@ -23,6 +23,7 @@ import org.apache.commons.math.exception
import org.apache.commons.math.exception.NoDataException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.FastMath;
/**
* Immutable representation of a real polynomial function with real coefficients.
@@ -140,8 +141,8 @@ public class PolynomialFunction implemen
public PolynomialFunction add(final PolynomialFunction p) {
// identify the lowest degree polynomial
- final int lowLength = Math.min(coefficients.length, p.coefficients.length);
- final int highLength = Math.max(coefficients.length, p.coefficients.length);
+ final int lowLength = FastMath.min(coefficients.length, p.coefficients.length);
+ final int highLength = FastMath.max(coefficients.length, p.coefficients.length);
// build the coefficients array
double[] newCoefficients = new double[highLength];
@@ -166,8 +167,8 @@ public class PolynomialFunction implemen
public PolynomialFunction subtract(final PolynomialFunction p) {
// identify the lowest degree polynomial
- int lowLength = Math.min(coefficients.length, p.coefficients.length);
- int highLength = Math.max(coefficients.length, p.coefficients.length);
+ int lowLength = FastMath.min(coefficients.length, p.coefficients.length);
+ int highLength = FastMath.max(coefficients.length, p.coefficients.length);
// build the coefficients array
double[] newCoefficients = new double[highLength];
@@ -210,8 +211,8 @@ public class PolynomialFunction implemen
for (int i = 0; i < newCoefficients.length; ++i) {
newCoefficients[i] = 0.0;
- for (int j = Math.max(0, i + 1 - p.coefficients.length);
- j < Math.min(coefficients.length, i + 1);
+ for (int j = FastMath.max(0, i + 1 - p.coefficients.length);
+ j < FastMath.min(coefficients.length, i + 1);
++j) {
newCoefficients[i] += coefficients[j] * p.coefficients[i-j];
}
@@ -305,7 +306,7 @@ public class PolynomialFunction implemen
}
}
- double absAi = Math.abs(coefficients[i]);
+ double absAi = FastMath.abs(coefficients[i]);
if ((absAi - 1) != 0) {
s.append(Double.toString(absAi));
s.append(' ');
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunctionLagrangeForm.java Sun Aug 29 22:04:09 2010
@@ -21,6 +21,7 @@ import org.apache.commons.math.FunctionE
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the representation of a real polynomial function in
@@ -179,7 +180,7 @@ public class PolynomialFunctionLagrangeF
c[i] = y[i];
d[i] = y[i];
// find out the abscissa closest to z
- final double dist = Math.abs(z - x[i]);
+ final double dist = FastMath.abs(z - x[i]);
if (dist < min_dist) {
nearest = i;
min_dist = dist;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialsUtils.java Sun Aug 29 22:04:09 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.analysis
import java.util.ArrayList;
import org.apache.commons.math.fraction.BigFraction;
+import org.apache.commons.math.util.FastMath;
/**
* A collection of static methods that operate on or return polynomials.
@@ -193,7 +194,7 @@ public class PolynomialsUtils {
final ArrayList<BigFraction> coefficients,
final RecurrenceCoefficientsGenerator generator) {
- final int maxDegree = (int) Math.floor(Math.sqrt(2 * coefficients.size())) - 1;
+ final int maxDegree = (int) FastMath.floor(FastMath.sqrt(2 * coefficients.size())) - 1;
synchronized (PolynomialsUtils.class) {
if (degree > maxDegree) {
computeUpToDegree(degree, maxDegree, generator, coefficients);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java Sun Aug 29 22:04:09 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.analysis
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/Bisection.html">
@@ -96,7 +97,7 @@ public class BisectionSolver extends Uni
max = m;
}
- if (Math.abs(max - min) <= absoluteAccuracy) {
+ if (FastMath.abs(max - min) <= absoluteAccuracy) {
m = UnivariateRealSolverUtils.midpoint(min, max);
setResult(m, i);
return m;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java Sun Aug 29 22:04:09 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/BrentsMethod.html">
@@ -136,14 +137,14 @@ public class BrentSolver extends Univari
// return the initial guess if it is good enough
double yInitial = f.value(initial);
- if (Math.abs(yInitial) <= functionValueAccuracy) {
+ if (FastMath.abs(yInitial) <= functionValueAccuracy) {
setResult(initial, 0);
return result;
}
// return the first endpoint if it is good enough
double yMin = f.value(min);
- if (Math.abs(yMin) <= functionValueAccuracy) {
+ if (FastMath.abs(yMin) <= functionValueAccuracy) {
setResult(min, 0);
return result;
}
@@ -155,7 +156,7 @@ public class BrentSolver extends Univari
// return the second endpoint if it is good enough
double yMax = f.value(max);
- if (Math.abs(yMax) <= functionValueAccuracy) {
+ if (FastMath.abs(yMax) <= functionValueAccuracy) {
setResult(max, 0);
return result;
}
@@ -204,10 +205,10 @@ public class BrentSolver extends Univari
double sign = yMin * yMax;
if (sign > 0) {
// check if either value is close to a zero
- if (Math.abs(yMin) <= functionValueAccuracy) {
+ if (FastMath.abs(yMin) <= functionValueAccuracy) {
setResult(min, 0);
ret = min;
- } else if (Math.abs(yMax) <= functionValueAccuracy) {
+ } else if (FastMath.abs(yMax) <= functionValueAccuracy) {
setResult(max, 0);
ret = max;
} else {
@@ -258,7 +259,7 @@ public class BrentSolver extends Univari
int i = 0;
while (i < maximalIterationCount) {
- if (Math.abs(y2) < Math.abs(y1)) {
+ if (FastMath.abs(y2) < FastMath.abs(y1)) {
// use the bracket point if is better than last approximation
x0 = x1;
x1 = x2;
@@ -267,7 +268,7 @@ public class BrentSolver extends Univari
y1 = y2;
y2 = y0;
}
- if (Math.abs(y1) <= functionValueAccuracy) {
+ if (FastMath.abs(y1) <= functionValueAccuracy) {
// Avoid division by very small values. Assume
// the iteration has converged (the problem may
// still be ill conditioned)
@@ -276,13 +277,13 @@ public class BrentSolver extends Univari
}
double dx = x2 - x1;
double tolerance =
- Math.max(relativeAccuracy * Math.abs(x1), absoluteAccuracy);
- if (Math.abs(dx) <= tolerance) {
+ FastMath.max(relativeAccuracy * FastMath.abs(x1), absoluteAccuracy);
+ if (FastMath.abs(dx) <= tolerance) {
setResult(x1, i);
return result;
}
- if ((Math.abs(oldDelta) < tolerance) ||
- (Math.abs(y0) <= Math.abs(y1))) {
+ if ((FastMath.abs(oldDelta) < tolerance) ||
+ (FastMath.abs(y0) <= FastMath.abs(y1))) {
// Force bisection.
delta = 0.5 * dx;
oldDelta = delta;
@@ -309,8 +310,8 @@ public class BrentSolver extends Univari
} else {
p = -p;
}
- if (2.0 * p >= 1.5 * dx * p1 - Math.abs(tolerance * p1) ||
- p >= Math.abs(0.5 * oldDelta * p1)) {
+ if (2.0 * p >= 1.5 * dx * p1 - FastMath.abs(tolerance * p1) ||
+ p >= FastMath.abs(0.5 * oldDelta * p1)) {
// Inverse quadratic interpolation gives a value
// in the wrong direction, or progress is slow.
// Fall back to bisection.
@@ -325,7 +326,7 @@ public class BrentSolver extends Univari
x0 = x1;
y0 = y1;
// Compute new X1, Y1
- if (Math.abs(delta) > tolerance) {
+ if (FastMath.abs(delta) > tolerance) {
x1 = x1 + delta;
} else if (dx > 0.0) {
x1 = x1 + 0.5 * tolerance;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/LaguerreSolver.java Sun Aug 29 22:04:09 2010
@@ -24,6 +24,7 @@ import org.apache.commons.math.analysis.
import org.apache.commons.math.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math.complex.Complex;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements the <a href="http://mathworld.wolfram.com/LaguerresMethod.html">
@@ -208,9 +209,9 @@ public class LaguerreSolver extends Univ
* @return true iff z is the sought-after real zero
*/
protected boolean isRootOK(double min, double max, Complex z) {
- double tolerance = Math.max(relativeAccuracy * z.abs(), absoluteAccuracy);
+ double tolerance = FastMath.max(relativeAccuracy * z.abs(), absoluteAccuracy);
return (isSequence(min, z.getReal(), max)) &&
- (Math.abs(z.getImaginary()) <= tolerance ||
+ (FastMath.abs(z.getImaginary()) <= tolerance ||
z.abs() <= functionValueAccuracy);
}
@@ -336,7 +337,7 @@ public class LaguerreSolver extends Univ
d2v = d2v.multiply(new Complex(2.0, 0.0));
// check for convergence
- double tolerance = Math.max(relativeAccuracy * z.abs(),
+ double tolerance = FastMath.max(relativeAccuracy * z.abs(),
absoluteAccuracy);
if ((z.subtract(oldz)).abs() <= tolerance) {
resultComputed = true;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/MullerSolver.java Sun Aug 29 22:04:09 2010
@@ -20,6 +20,7 @@ import org.apache.commons.math.Convergen
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
/**
@@ -167,20 +168,20 @@ public class MullerSolver extends Univar
final double d012 = (d12 - d01) / (x2 - x0);
final double c1 = d01 + (x1 - x0) * d012;
final double delta = c1 * c1 - 4 * y1 * d012;
- final double xplus = x1 + (-2.0 * y1) / (c1 + Math.sqrt(delta));
- final double xminus = x1 + (-2.0 * y1) / (c1 - Math.sqrt(delta));
+ final double xplus = x1 + (-2.0 * y1) / (c1 + FastMath.sqrt(delta));
+ final double xminus = x1 + (-2.0 * y1) / (c1 - FastMath.sqrt(delta));
// xplus and xminus are two roots of parabola and at least
// one of them should lie in (x0, x2)
final double x = isSequence(x0, xplus, x2) ? xplus : xminus;
final double y = f.value(x);
// check for convergence
- final double tolerance = Math.max(relativeAccuracy * Math.abs(x), absoluteAccuracy);
- if (Math.abs(x - oldx) <= tolerance) {
+ final double tolerance = FastMath.max(relativeAccuracy * FastMath.abs(x), absoluteAccuracy);
+ if (FastMath.abs(x - oldx) <= tolerance) {
setResult(x, i);
return result;
}
- if (Math.abs(y) <= functionValueAccuracy) {
+ if (FastMath.abs(y) <= functionValueAccuracy) {
setResult(x, i);
return result;
}
@@ -307,12 +308,12 @@ public class MullerSolver extends Univar
final double denominator;
if (delta >= 0.0) {
// choose a denominator larger in magnitude
- double dplus = b + Math.sqrt(delta);
- double dminus = b - Math.sqrt(delta);
- denominator = Math.abs(dplus) > Math.abs(dminus) ? dplus : dminus;
+ double dplus = b + FastMath.sqrt(delta);
+ double dminus = b - FastMath.sqrt(delta);
+ denominator = FastMath.abs(dplus) > FastMath.abs(dminus) ? dplus : dminus;
} else {
- // take the modulus of (B +/- Math.sqrt(delta))
- denominator = Math.sqrt(b * b - delta);
+ // take the modulus of (B +/- FastMath.sqrt(delta))
+ denominator = FastMath.sqrt(b * b - delta);
}
if (denominator != 0) {
x = x2 - 2.0 * c * (x2 - x1) / denominator;
@@ -323,18 +324,18 @@ public class MullerSolver extends Univar
}
} else {
// extremely rare case, get a random number to skip it
- x = min + Math.random() * (max - min);
+ x = min + FastMath.random() * (max - min);
oldx = Double.POSITIVE_INFINITY;
}
final double y = f.value(x);
// check for convergence
- final double tolerance = Math.max(relativeAccuracy * Math.abs(x), absoluteAccuracy);
- if (Math.abs(x - oldx) <= tolerance) {
+ final double tolerance = FastMath.max(relativeAccuracy * FastMath.abs(x), absoluteAccuracy);
+ if (FastMath.abs(x - oldx) <= tolerance) {
setResult(x, i);
return result;
}
- if (Math.abs(y) <= functionValueAccuracy) {
+ if (FastMath.abs(y) <= functionValueAccuracy) {
setResult(x, i);
return result;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/NewtonSolver.java Sun Aug 29 22:04:09 2010
@@ -23,6 +23,7 @@ import org.apache.commons.math.MaxIterat
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
* Implements <a href="http://mathworld.wolfram.com/NewtonsMethod.html">
@@ -119,7 +120,7 @@ public class NewtonSolver extends Univar
while (i < maximalIterationCount) {
x1 = x0 - (f.value(x0) / derivative.value(x0));
- if (Math.abs(x1 - x0) <= absoluteAccuracy) {
+ if (FastMath.abs(x1 - x0) <= absoluteAccuracy) {
setResult(x1, i);
return x1;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/RiddersSolver.java Sun Aug 29 22:04:09 2010
@@ -20,6 +20,7 @@ import org.apache.commons.math.Convergen
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
/**
@@ -145,23 +146,23 @@ public class RiddersSolver extends Univa
// calculate the new root approximation
final double x3 = 0.5 * (x1 + x2);
final double y3 = f.value(x3);
- if (Math.abs(y3) <= functionValueAccuracy) {
+ if (FastMath.abs(y3) <= functionValueAccuracy) {
setResult(x3, i);
return result;
}
final double delta = 1 - (y1 * y2) / (y3 * y3); // delta > 1 due to bracketing
final double correction = (MathUtils.sign(y2) * MathUtils.sign(y3)) *
- (x3 - x1) / Math.sqrt(delta);
+ (x3 - x1) / FastMath.sqrt(delta);
final double x = x3 - correction; // correction != 0
final double y = f.value(x);
// check for convergence
- final double tolerance = Math.max(relativeAccuracy * Math.abs(x), absoluteAccuracy);
- if (Math.abs(x - oldx) <= tolerance) {
+ final double tolerance = FastMath.max(relativeAccuracy * FastMath.abs(x), absoluteAccuracy);
+ if (FastMath.abs(x - oldx) <= tolerance) {
setResult(x, i);
return result;
}
- if (Math.abs(y) <= functionValueAccuracy) {
+ if (FastMath.abs(y) <= functionValueAccuracy) {
setResult(x, i);
return result;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/SecantSolver.java Sun Aug 29 22:04:09 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.MaxIterationsExceededException;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
/**
@@ -136,7 +137,7 @@ public class SecantSolver extends Univar
double oldDelta = x2 - x1;
int i = 0;
while (i < maximalIterationCount) {
- if (Math.abs(y2) < Math.abs(y1)) {
+ if (FastMath.abs(y2) < FastMath.abs(y1)) {
x0 = x1;
x1 = x2;
x2 = x0;
@@ -144,17 +145,17 @@ public class SecantSolver extends Univar
y1 = y2;
y2 = y0;
}
- if (Math.abs(y1) <= functionValueAccuracy) {
+ if (FastMath.abs(y1) <= functionValueAccuracy) {
setResult(x1, i);
return result;
}
- if (Math.abs(oldDelta) <
- Math.max(relativeAccuracy * Math.abs(x1), absoluteAccuracy)) {
+ if (FastMath.abs(oldDelta) <
+ FastMath.max(relativeAccuracy * FastMath.abs(x1), absoluteAccuracy)) {
setResult(x1, i);
return result;
}
double delta;
- if (Math.abs(y1) > Math.abs(y0)) {
+ if (FastMath.abs(y1) > FastMath.abs(y0)) {
// Function value increased in last iteration. Force bisection.
delta = 0.5 * oldDelta;
} else {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java Sun Aug 29 22:04:09 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.MathRunti
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.exception.NullArgumentException;
+import org.apache.commons.math.util.FastMath;
/**
* Utility routines for {@link UnivariateRealSolver} objects.
@@ -189,8 +190,8 @@ public class UnivariateRealSolverUtils {
int numIterations = 0 ;
do {
- a = Math.max(a - 1.0, lowerBound);
- b = Math.min(b + 1.0, upperBound);
+ a = FastMath.max(a - 1.0, lowerBound);
+ b = FastMath.min(b + 1.0, upperBound);
fa = function.value(a);
fb = function.value(b);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/complex/Complex.java Sun Aug 29 22:04:09 2010
@@ -25,6 +25,7 @@ import org.apache.commons.math.FieldElem
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.util.MathUtils;
+import org.apache.commons.math.util.FastMath;
/**
* Representation of a Complex number - a number which has both a
@@ -113,18 +114,18 @@ public class Complex implements FieldEle
return Double.POSITIVE_INFINITY;
}
- if (Math.abs(real) < Math.abs(imaginary)) {
+ if (FastMath.abs(real) < FastMath.abs(imaginary)) {
if (imaginary == 0.0) {
- return Math.abs(real);
+ return FastMath.abs(real);
}
double q = real / imaginary;
- return Math.abs(imaginary) * Math.sqrt(1 + q * q);
+ return FastMath.abs(imaginary) * FastMath.sqrt(1 + q * q);
} else {
if (real == 0.0) {
- return Math.abs(imaginary);
+ return FastMath.abs(imaginary);
}
double q = imaginary / real;
- return Math.abs(real) * Math.sqrt(1 + q * q);
+ return FastMath.abs(real) * FastMath.sqrt(1 + q * q);
}
}
@@ -221,7 +222,7 @@ public class Complex implements FieldEle
return ZERO;
}
- if (Math.abs(c) < Math.abs(d)) {
+ if (FastMath.abs(c) < FastMath.abs(d)) {
double q = c / d;
double denominator = c * q + d;
return createComplex((real * q + imaginary) / denominator,
@@ -547,8 +548,8 @@ public class Complex implements FieldEle
return Complex.NaN;
}
- return createComplex(Math.cos(real) * MathUtils.cosh(imaginary),
- -Math.sin(real) * MathUtils.sinh(imaginary));
+ return createComplex(FastMath.cos(real) * MathUtils.cosh(imaginary),
+ -FastMath.sin(real) * MathUtils.sinh(imaginary));
}
/**
@@ -581,8 +582,8 @@ public class Complex implements FieldEle
return Complex.NaN;
}
- return createComplex(MathUtils.cosh(real) * Math.cos(imaginary),
- MathUtils.sinh(real) * Math.sin(imaginary));
+ return createComplex(MathUtils.cosh(real) * FastMath.cos(imaginary),
+ MathUtils.sinh(real) * FastMath.sin(imaginary));
}
/**
@@ -616,8 +617,8 @@ public class Complex implements FieldEle
return Complex.NaN;
}
- double expReal = Math.exp(real);
- return createComplex(expReal * Math.cos(imaginary), expReal * Math.sin(imaginary));
+ double expReal = FastMath.exp(real);
+ return createComplex(expReal * FastMath.cos(imaginary), expReal * FastMath.sin(imaginary));
}
/**
@@ -654,8 +655,8 @@ public class Complex implements FieldEle
return Complex.NaN;
}
- return createComplex(Math.log(abs()),
- Math.atan2(imaginary, real));
+ return createComplex(FastMath.log(abs()),
+ FastMath.atan2(imaginary, real));
}
/**
@@ -713,8 +714,8 @@ public class Complex implements FieldEle
return Complex.NaN;
}
- return createComplex(Math.sin(real) * MathUtils.cosh(imaginary),
- Math.cos(real) * MathUtils.sinh(imaginary));
+ return createComplex(FastMath.sin(real) * MathUtils.cosh(imaginary),
+ FastMath.cos(real) * MathUtils.sinh(imaginary));
}
/**
@@ -747,8 +748,8 @@ public class Complex implements FieldEle
return Complex.NaN;
}
- return createComplex(MathUtils.sinh(real) * Math.cos(imaginary),
- MathUtils.cosh(real) * Math.sin(imaginary));
+ return createComplex(MathUtils.sinh(real) * FastMath.cos(imaginary),
+ MathUtils.cosh(real) * FastMath.sin(imaginary));
}
/**
@@ -793,11 +794,11 @@ public class Complex implements FieldEle
return createComplex(0.0, 0.0);
}
- double t = Math.sqrt((Math.abs(real) + abs()) / 2.0);
+ double t = FastMath.sqrt((FastMath.abs(real) + abs()) / 2.0);
if (real >= 0.0) {
return createComplex(t, imaginary / (2.0 * t));
} else {
- return createComplex(Math.abs(imaginary) / (2.0 * t),
+ return createComplex(FastMath.abs(imaginary) / (2.0 * t),
MathUtils.indicator(imaginary) * t);
}
}
@@ -857,9 +858,9 @@ public class Complex implements FieldEle
double real2 = 2.0 * real;
double imaginary2 = 2.0 * imaginary;
- double d = Math.cos(real2) + MathUtils.cosh(imaginary2);
+ double d = FastMath.cos(real2) + MathUtils.cosh(imaginary2);
- return createComplex(Math.sin(real2) / d, MathUtils.sinh(imaginary2) / d);
+ return createComplex(FastMath.sin(real2) / d, MathUtils.sinh(imaginary2) / d);
}
/**
@@ -895,9 +896,9 @@ public class Complex implements FieldEle
double real2 = 2.0 * real;
double imaginary2 = 2.0 * imaginary;
- double d = MathUtils.cosh(real2) + Math.cos(imaginary2);
+ double d = MathUtils.cosh(real2) + FastMath.cos(imaginary2);
- return createComplex(MathUtils.sinh(real2) / d, Math.sin(imaginary2) / d);
+ return createComplex(MathUtils.sinh(real2) / d, FastMath.sin(imaginary2) / d);
}
@@ -917,7 +918,7 @@ public class Complex implements FieldEle
* @return the argument of this complex number
*/
public double getArgument() {
- return Math.atan2(getImaginary(), getReal());
+ return FastMath.atan2(getImaginary(), getReal());
}
/**
@@ -959,16 +960,16 @@ public class Complex implements FieldEle
}
// nth root of abs -- faster / more accurate to use a solver here?
- final double nthRootOfAbs = Math.pow(abs(), 1.0 / n);
+ final double nthRootOfAbs = FastMath.pow(abs(), 1.0 / n);
// Compute nth roots of complex number with k = 0, 1, ... n-1
final double nthPhi = getArgument()/n;
- final double slice = 2 * Math.PI / n;
+ final double slice = 2 * FastMath.PI / n;
double innerPart = nthPhi;
for (int k = 0; k < n ; k++) {
// inner part
- final double realPart = nthRootOfAbs * Math.cos(innerPart);
- final double imaginaryPart = nthRootOfAbs * Math.sin(innerPart);
+ final double realPart = nthRootOfAbs * FastMath.cos(innerPart);
+ final double imaginaryPart = nthRootOfAbs * FastMath.sin(innerPart);
result.add(createComplex(realPart, imaginaryPart));
innerPart += slice;
}
Re: svn commit: r990658 [1/10] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/analysis/ src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/analysis/interpolation/ src/main/java/org/a...
Posted by Phil Steitz <ph...@gmail.com>.
luc@apache.org wrote:
> Author: luc
> Date: Sun Aug 29 22:04:09 2010
> New Revision: 990658
>
> URL: http://svn.apache.org/viewvc?rev=990658&view=rev
> Log:
> added FastMath and used it everywhere in replacement of java.util.Math
> the unit tests have not been added yet (waiting for dfp library addition)
> JIRA: MATH-375
>
> <contributor>
> + <name>Bill Rossi</name>
> + </contributor>
> + <contributor>
> <name>Matthew Rowles</name>
> </contributor>
> <contributor>
>
Thanks, Luc!
And *welcome* Bill!
Phil
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org