You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ps...@apache.org on 2005/12/22 22:17:07 UTC
svn commit: r358631 [2/3] - in /jakarta/commons/proper/math/trunk: ./
src/conf/ src/java/org/apache/commons/math/
src/java/org/apache/commons/math/analysis/
src/java/org/apache/commons/math/complex/
src/java/org/apache/commons/math/distribution/ src/ja...
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/Frequency.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/Frequency.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/Frequency.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/Frequency.java Thu Dec 22 13:16:32 2005
@@ -40,7 +40,7 @@
public class Frequency implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -3845586908418844111L;
+ private static final long serialVersionUID = -3845586908418844111L;
/** underlying collection */
private TreeMap freqTable = null;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractStorelessUnivariateStatistic.java Thu Dec 22 13:16:32 2005
@@ -20,7 +20,7 @@
/**
*
- * Abstract Implementation for the {@link StorelessUnivariateStatistic} interface.
+ * Abstract implementation of the {@link StorelessUnivariateStatistic} interface.
* <p>
* Provides default <code>evaluate()</code> and <code>incrementAll(double[])<code>
* implementations.
@@ -34,7 +34,7 @@
implements StorelessUnivariateStatistic, Serializable {
/** Serialization UID */
- static final long serialVersionUID = -44915725420072521L;
+ private static final long serialVersionUID = -44915725420072521L;
/**
* This default implementation calls {@link #clear}, then invokes
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatistic.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatistic.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatistic.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AbstractUnivariateStatistic.java Thu Dec 22 13:16:32 2005
@@ -34,7 +34,7 @@
implements UnivariateStatistic, Serializable {
/** Serialization UID */
- static final long serialVersionUID = -8007759382851708045L;
+ private static final long serialVersionUID = -8007759382851708045L;
/**
* @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[])
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java Thu Dec 22 13:16:32 2005
@@ -39,7 +39,7 @@
public abstract class DescriptiveStatistics implements StatisticalSummary, Serializable {
/** Serialization UID */
- static final long serialVersionUID = 5188298269533339922L;
+ private static final long serialVersionUID = 5188298269533339922L;
/**
* Create an instance of a <code>DescriptiveStatistics</code>
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsImpl.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsImpl.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsImpl.java Thu Dec 22 13:16:32 2005
@@ -28,7 +28,7 @@
public class DescriptiveStatisticsImpl extends DescriptiveStatistics implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -1868088725461221010L;
+ private static final long serialVersionUID = -1868088725461221010L;
/** hold the window size **/
protected int windowSize;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java Thu Dec 22 13:16:32 2005
@@ -27,7 +27,7 @@
StatisticalSummary {
/** Serialization id */
- static final long serialVersionUID = -5108854841843722536L;
+ private static final long serialVersionUID = -5108854841843722536L;
/** The sample mean */
private final double mean;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java Thu Dec 22 13:16:32 2005
@@ -28,7 +28,7 @@
public abstract class SummaryStatistics implements StatisticalSummary, Serializable {
/** Serialization UID */
- static final long serialVersionUID = -6400596334135654825L;
+ private static final long serialVersionUID = -6400596334135654825L;
/**
* Create an instance of a <code>SummaryStatistics</code>
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsImpl.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsImpl.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SummaryStatisticsImpl.java Thu Dec 22 13:16:32 2005
@@ -34,7 +34,7 @@
public class SummaryStatisticsImpl extends SummaryStatistics implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 8787174276883311692L;
+ private static final long serialVersionUID = 8787174276883311692L;
/** count of values that have been added */
protected long n = 0;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FirstMoment.java Thu Dec 22 13:16:32 2005
@@ -48,7 +48,7 @@
implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -803343206421984070L;
+ private static final long serialVersionUID = -803343206421984070L;
/** Count of values that have been added */
protected long n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/FourthMoment.java Thu Dec 22 13:16:32 2005
@@ -52,7 +52,7 @@
public class FourthMoment extends ThirdMoment implements Serializable{
/** Serializable version identifier */
- static final long serialVersionUID = 4763990447117157611L;
+ private static final long serialVersionUID = 4763990447117157611L;
/** fourth moment of values that have been added */
protected double m4;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/GeometricMean.java Thu Dec 22 13:16:32 2005
@@ -45,7 +45,7 @@
public class GeometricMean extends AbstractStorelessUnivariateStatistic {
/** Serializable version identifier */
- static final long serialVersionUID = -8178734905303459453L;
+ private static final long serialVersionUID = -8178734905303459453L;
/** Wrapped SumOfLogs instance */
private SumOfLogs sumOfLogs;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Kurtosis.java Thu Dec 22 13:16:32 2005
@@ -40,7 +40,7 @@
public class Kurtosis extends AbstractStorelessUnivariateStatistic {
/** Serializable version identifier */
- static final long serialVersionUID = 2784465764798260919L;
+ private static final long serialVersionUID = 2784465764798260919L;
/**Fourth Moment on which this statistic is based */
protected FourthMoment moment;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Mean.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Mean.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Mean.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Mean.java Thu Dec 22 13:16:32 2005
@@ -50,7 +50,7 @@
implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -1296043746617791564L;
+ private static final long serialVersionUID = -1296043746617791564L;
/** First moment on which this statistic is based. */
protected FirstMoment moment;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/SecondMoment.java Thu Dec 22 13:16:32 2005
@@ -44,7 +44,7 @@
public class SecondMoment extends FirstMoment implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 3942403127395076445L;
+ private static final long serialVersionUID = 3942403127395076445L;
/** second moment of values that have been added */
protected double m2;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Skewness.java Thu Dec 22 13:16:32 2005
@@ -39,7 +39,7 @@
public class Skewness extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 7101857578996691352L;
+ private static final long serialVersionUID = 7101857578996691352L;
/** Third moment on which this statistic is based */
protected ThirdMoment moment = null;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java Thu Dec 22 13:16:32 2005
@@ -40,7 +40,7 @@
implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 5728716329662425188L;
+ private static final long serialVersionUID = 5728716329662425188L;
/** Wrapped Variance instance */
private Variance variance = null;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java Thu Dec 22 13:16:32 2005
@@ -45,7 +45,7 @@
public class ThirdMoment extends SecondMoment implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -7818711964045118679L;
+ private static final long serialVersionUID = -7818711964045118679L;
/** third moment of values that have been added */
protected double m3;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Variance.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Variance.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Variance.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/moment/Variance.java Thu Dec 22 13:16:32 2005
@@ -50,7 +50,7 @@
public class Variance extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -9111962718267217978L;
+ private static final long serialVersionUID = -9111962718267217978L;
/** SecondMoment is used in incremental calculation of Variance*/
protected SecondMoment moment = null;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Max.java Thu Dec 22 13:16:32 2005
@@ -37,7 +37,7 @@
public class Max extends AbstractStorelessUnivariateStatistic {
/** Serializable version identifier */
- static final long serialVersionUID = -5593383832225844641L;
+ private static final long serialVersionUID = -5593383832225844641L;
/** Number of values that have been added */
private long n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Median.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Median.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Median.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Median.java Thu Dec 22 13:16:32 2005
@@ -32,7 +32,7 @@
public class Median extends Percentile implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -3961477041290915687L;
+ private static final long serialVersionUID = -3961477041290915687L;
/**
* Default constructor.
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Min.java Thu Dec 22 13:16:32 2005
@@ -39,7 +39,7 @@
public class Min extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -2941995784909003131L;
+ private static final long serialVersionUID = -2941995784909003131L;
/**Number of values that have been added */
private long n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java Thu Dec 22 13:16:32 2005
@@ -65,7 +65,7 @@
public class Percentile extends AbstractUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -8091216485095130416L;
+ private static final long serialVersionUID = -8091216485095130416L;
/** Determines what percentile is computed when evaluate() is activated
* with no quantile argument */
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Product.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Product.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Product.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Product.java Thu Dec 22 13:16:32 2005
@@ -35,7 +35,7 @@
public class Product extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 2824226005990582538L;
+ private static final long serialVersionUID = 2824226005990582538L;
/**The number of values that have been added */
private long n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Sum.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Sum.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Sum.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/Sum.java Thu Dec 22 13:16:32 2005
@@ -35,7 +35,7 @@
public class Sum extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -8231831954703408316L;
+ private static final long serialVersionUID = -8231831954703408316L;
/** */
private long n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java Thu Dec 22 13:16:32 2005
@@ -43,7 +43,7 @@
public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -370076995648386763L;
+ private static final long serialVersionUID = -370076995648386763L;
/**Number of values that have been added */
private int n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java Thu Dec 22 13:16:32 2005
@@ -35,7 +35,7 @@
public class SumOfSquares extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 1460986908574398008L;
+ private static final long serialVersionUID = 1460986908574398008L;
/** */
private long n;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java Thu Dec 22 13:16:32 2005
@@ -54,7 +54,7 @@
public class SimpleRegression implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -3004689053607543335L;
+ private static final long serialVersionUID = -3004689053607543335L;
/** sum of x values */
private double sumX = 0d;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ContinuedFraction.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ContinuedFraction.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ContinuedFraction.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ContinuedFraction.java Thu Dec 22 13:16:32 2005
@@ -37,7 +37,7 @@
public abstract class ContinuedFraction implements Serializable {
/** Serialization UID */
- static final long serialVersionUID = 1768555336266158242L;
+ private static final long serialVersionUID = 1768555336266158242L;
/** Maximum allowed numerical error. */
private static final double DEFAULT_EPSILON = 10e-9;
@@ -128,46 +128,46 @@
public double evaluate(double x, double epsilon, int maxIterations)
throws MathException
{
- double p0 = 1.0;
- double p1 = getA(0, x);
- double q0 = 0.0;
- double q1 = 1.0;
- double c = p1 / q1;
- int n = 0;
- double relativeError = Double.MAX_VALUE;
- while (n < maxIterations && relativeError > epsilon) {
- ++n;
- double a = getA(n, x);
- double b = getB(n, x);
- double p2 = a * p1 + b * p0;
- double q2 = a * q1 + b * q0;
- if (Double.isInfinite(p2) || Double.isInfinite(q2)) {
- // need to scale
- if (a != 0.0) {
- p2 = p1 + (b / a * p0);
- q2 = q1 + (b / a * q0);
- } else if (b != 0) {
- p2 = (a / b * p1) + p0;
- q2 = (a / b * q1) + q0;
- } else {
- // can not scale an convergent is unbounded.
- throw new ConvergenceException(
- "Continued fraction convergents diverged to +/- " +
- "infinity.");
- }
- }
- double r = p2 / q2;
- relativeError = Math.abs(r / c - 1.0);
-
- // prepare for next iteration
- c = p2 / q2;
- p0 = p1;
- p1 = p2;
- q0 = q1;
- q1 = q2;
- }
+ double p0 = 1.0;
+ double p1 = getA(0, x);
+ double q0 = 0.0;
+ double q1 = 1.0;
+ double c = p1 / q1;
+ int n = 0;
+ double relativeError = Double.MAX_VALUE;
+ while (n < maxIterations && relativeError > epsilon) {
+ ++n;
+ double a = getA(n, x);
+ double b = getB(n, x);
+ double p2 = a * p1 + b * p0;
+ double q2 = a * q1 + b * q0;
+ if (Double.isInfinite(p2) || Double.isInfinite(q2)) {
+ // need to scale
+ if (a != 0.0) {
+ p2 = p1 + (b / a * p0);
+ q2 = q1 + (b / a * q0);
+ } else if (b != 0) {
+ p2 = (a / b * p1) + p0;
+ q2 = (a / b * q1) + q0;
+ } else {
+ // can not scale an convergent is unbounded.
+ throw new ConvergenceException(
+ "Continued fraction convergents diverged to +/- " +
+ "infinity.");
+ }
+ }
+ double r = p2 / q2;
+ relativeError = Math.abs(r / c - 1.0);
+
+ // prepare for next iteration
+ c = p2 / q2;
+ p0 = p1;
+ p1 = p2;
+ q0 = q1;
+ q1 = q2;
+ }
- if (n >= maxIterations) {
+ if (n >= maxIterations) {
throw new ConvergenceException(
"Continued fraction convergents failed to converge.");
}
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/DefaultTransformer.java Thu Dec 22 13:16:32 2005
@@ -31,7 +31,7 @@
public class DefaultTransformer implements NumberTransformer, Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = 4019938025047800455L;
+ private static final long serialVersionUID = 4019938025047800455L;
/**
* @param o the object that gets transformed.
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/ResizableDoubleArray.java Thu Dec 22 13:16:32 2005
@@ -71,7 +71,7 @@
public class ResizableDoubleArray implements DoubleArray, Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -3485529955529426875L;
+ private static final long serialVersionUID = -3485529955529426875L;
/** additive expansion mode */
public static final int ADDITIVE_MODE = 1;
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/TransformerMap.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/TransformerMap.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/TransformerMap.java (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/TransformerMap.java Thu Dec 22 13:16:32 2005
@@ -33,7 +33,7 @@
public class TransformerMap implements NumberTransformer, Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -942772950698439883L;
+ private static final long serialVersionUID = -942772950698439883L;
/**
* A default Number Transformer for Numbers and numeric Strings.
Modified: jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/package.html
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/package.html?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/package.html (original)
+++ jakarta/commons/proper/math/trunk/src/java/org/apache/commons/math/util/package.html Thu Dec 22 13:16:32 2005
@@ -15,5 +15,5 @@
limitations under the License.
-->
<!-- $Revision$ $Date$ -->
- <body>Convience routines and common data structure used throughout the commons-math library.</body>
+ <body>Convenience routines and common data structures used throughout the commons-math library.</body>
</html>
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/TestUtils.java Thu Dec 22 13:16:32 2005
@@ -42,6 +42,10 @@
assertEquals(null, expected, actual, delta);
}
+ /**
+ * Verifies that expected and actual are within delta, or are both NaN or
+ * infinities of the same sign.
+ */
public static void assertEquals(String msg, double expected, double actual, double delta) {
// check for NaN
if(Double.isNaN(expected)){
@@ -52,8 +56,26 @@
}
}
+ /*
+ * Verifies that the two arguments are exactly the same, either
+ * both NaN or infinities of same sign, or identical floating point values.
+ */
+ public static void assertSame(double expected, double actual) {
+ assertEquals(expected, actual, 0);
+ }
+
/**
- *
+ * Verifies that real and imaginary parts of the two complex arguments
+ * are exactly the same. Also ensures that NaN / infinite components match.
+ */
+ public static void assertSame(Complex expected, Complex actual) {
+ assertSame(expected.getReal(), actual.getReal());
+ assertSame(expected.getImaginary(), actual.getImaginary());
+ }
+
+ /**
+ * Verifies that real and imaginary parts of the two complex arguments
+ * differ by at most delta. Also ensures that NaN / infinite components match.
*/
public static void assertEquals(Complex expected, Complex actual, double delta) {
assertEquals(expected.getReal(), actual.getReal(), delta);
@@ -92,26 +114,26 @@
ObjectInputStream si = new ObjectInputStream(fi);
result = si.readObject();
} catch (Exception ex) {
-
+
} finally {
- if (fo != null) {
- try {
- fo.close();
- } catch (IOException ex) {
- }
- }
+ if (fo != null) {
+ try {
+ fo.close();
+ } catch (IOException ex) {
+ }
+ }
- if (fi != null) {
- try {
- fi.close();
- } catch (IOException ex) {
- }
- }
+ if (fi != null) {
+ try {
+ fi.close();
+ } catch (IOException ex) {
+ }
+ }
}
if (tmp != null) {
- tmp.delete();
+ tmp.delete();
}
return result;
@@ -128,15 +150,15 @@
Assert.assertEquals("HashCode check", object.hashCode(), object2.hashCode());
}
- public static void assertRelativelyEquals(double expected, double actual, double relativeError) {
- assertRelativelyEquals(null, expected, actual, relativeError);
- }
-
- public static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError) {
+ public static void assertRelativelyEquals(double expected, double actual, double relativeError) {
+ assertRelativelyEquals(null, expected, actual, relativeError);
+ }
+
+ public static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError) {
if (Double.isNaN(expected)) {
Assert.assertTrue(msg, Double.isNaN(actual));
} else if (Double.isNaN(actual)) {
- Assert.assertTrue(msg, Double.isNaN(expected));
+ Assert.assertTrue(msg, Double.isNaN(expected));
} else if (Double.isInfinite(actual) || Double.isInfinite(expected)) {
Assert.assertEquals(expected, actual, relativeError);
} else if (expected == 0.0) {
@@ -145,5 +167,5 @@
double x = Math.abs((expected - actual) / expected);
Assert.assertEquals(msg, 0.0, x, relativeError);
}
- }
+ }
}
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/LaguerreSolverTest.java Thu Dec 22 13:16:32 2005
@@ -131,17 +131,17 @@
expected = new Complex(0.5, 0.5 * Math.sqrt(3.0));
tolerance = Math.max(solver.getAbsoluteAccuracy(),
Math.abs(expected.abs() * solver.getRelativeAccuracy()));
- assertEquals(0.0, (expected.subtract(result[2])).abs(), tolerance);
+ assertEquals(0.0, (expected.subtract(result[3])).abs(), tolerance);
expected = new Complex(-1.0, 0.0);
tolerance = Math.max(solver.getAbsoluteAccuracy(),
Math.abs(expected.abs() * solver.getRelativeAccuracy()));
- assertEquals(0.0, (expected.subtract(result[3])).abs(), tolerance);
+ assertEquals(0.0, (expected.subtract(result[4])).abs(), tolerance);
expected = new Complex(0.5, -0.5 * Math.sqrt(3.0));
tolerance = Math.max(solver.getAbsoluteAccuracy(),
Math.abs(expected.abs() * solver.getRelativeAccuracy()));
- assertEquals(0.0, (expected.subtract(result[4])).abs(), tolerance);
+ assertEquals(0.0, (expected.subtract(result[2])).abs(), tolerance);
}
/**
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/NewtonSolverTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/NewtonSolverTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/NewtonSolverTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/NewtonSolverTest.java Thu Dec 22 13:16:32 2005
@@ -18,6 +18,8 @@
package org.apache.commons.math.analysis;
import org.apache.commons.math.MathException;
+import org.apache.commons.math.TestUtils;
+
import junit.framework.TestCase;
@@ -84,5 +86,80 @@
result = solver.solve(0.85, 5);
assertEquals(result, 1.0, solver.getAbsoluteAccuracy());
+ }
+
+ /**
+ * Test Serialization and Recovery
+ */
+ public void testSerialization() throws MathException {
+ DifferentiableUnivariateRealFunction f = new QuinticFunction();
+ double result;
+
+ NewtonSolver solver = new NewtonSolver(f);
+ NewtonSolver solver2 = (NewtonSolver)TestUtils.serializeAndRecover(solver);
+
+ result = solver.solve(-0.2, 0.2);
+ assertEquals(result, 0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(-0.2, 0.2), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(-0.1, 0.3);
+ assertEquals(result, 0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(-0.1, 0.3), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(-0.3, 0.45);
+ assertEquals(result, 0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(-0.3, 0.45), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.3, 0.7);
+ assertEquals(result, 0.5, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.3, 0.7), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.2, 0.6);
+ assertEquals(result, 0.5, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.2, 0.6), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.05, 0.95);
+ assertEquals(result, 0.5, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.05, 0.95), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.85, 1.25);
+ assertEquals(result, 1.0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.85, 1.25), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.8, 1.2);
+ assertEquals(result, 1.0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.8, 1.2), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.85, 1.75);
+ assertEquals(result, 1.0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.85, 1.75), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.55, 1.45);
+ assertEquals(result, 1.0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.55, 1.45), result, solver2.getAbsoluteAccuracy());
+
+ result = solver.solve(0.85, 5);
+ assertEquals(result, 1.0, solver.getAbsoluteAccuracy());
+ assertEquals(solver2.solve(0.85, 5), result, solver2.getAbsoluteAccuracy());
+
+ /* Test Reset */
+ double newValue = 1.0e-2;
+ f = new QuinticFunction();
+ solver = new NewtonSolver(f);
+
+ double oldValue = solver.getRelativeAccuracy();
+ solver.setRelativeAccuracy(newValue);
+ solver.resetRelativeAccuracy();
+ assertEquals(oldValue, solver.getRelativeAccuracy(), 1.0e-2);
+
+ solver2 = (NewtonSolver)TestUtils.serializeAndRecover(solver);
+
+ assertEquals(oldValue, solver2.getRelativeAccuracy(), 1.0e-2);
+
+ solver2.setRelativeAccuracy(newValue);
+ solver2.resetRelativeAccuracy();
+
+ assertEquals(oldValue, solver2.getRelativeAccuracy(), 1.0e-2);
+
}
}
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/QuinticFunction.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/QuinticFunction.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/QuinticFunction.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/analysis/QuinticFunction.java Thu Dec 22 13:16:32 2005
@@ -26,7 +26,7 @@
*/
public class QuinticFunction implements DifferentiableUnivariateRealFunction, Serializable {
- static final long serialVersionUID = -8866263034920607152L;
+ private static final long serialVersionUID = -8866263034920607152L;
/* Evaluate quintic.
* @see org.apache.commons.math.UnivariateRealFunction#value(double)
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java Thu Dec 22 13:16:32 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,16 @@
*/
public class ComplexTest extends TestCase {
+ private double inf = Double.POSITIVE_INFINITY;
+ private double neginf = Double.NEGATIVE_INFINITY;
+ private double nan = Double.NaN;
+ private Complex oneInf = new Complex(1, inf);
+ private Complex oneNegInf = new Complex(1, neginf);
+ private Complex infOne = new Complex(inf, 1);
+ private Complex negInfInf = new Complex(neginf, inf);
+ private Complex negInfNegInf = new Complex(neginf, neginf);
+ private Complex oneNaN = new Complex(1, nan);
+
public void testConstructor() {
Complex z = new Complex(3.0, 4.0);
assertEquals(3.0, z.getReal(), 1.0e-5);
@@ -33,7 +43,7 @@
Complex z = new Complex(3.0, Double.NaN);
assertTrue(z.isNaN());
- z = new Complex(Double.NaN, 4.0);
+ z = new Complex(nan, 4.0);
assertTrue(z.isNaN());
z = new Complex(3.0, 4.0);
@@ -47,6 +57,17 @@
public void testAbsNaN() {
assertTrue(Double.isNaN(Complex.NaN.abs()));
+ Complex z = new Complex(inf, nan);
+ assertTrue(Double.isNaN(z.abs()));
+ }
+
+ public void testAbsInfinite() {
+ Complex z = new Complex(inf, 0);
+ assertEquals(inf, z.abs(), 0);
+ z = new Complex(0, neginf);
+ assertEquals(inf, z.abs(), 0);
+ z = new Complex(inf, neginf);
+ assertEquals(inf, z.abs(), 0);
}
public void testAdd() {
@@ -61,6 +82,21 @@
Complex x = new Complex(3.0, 4.0);
Complex z = x.add(Complex.NaN);
assertTrue(z.isNaN());
+ z = new Complex(1, nan);
+ Complex w = x.add(z);
+ assertEquals(w.real, 4.0, 0);
+ assertTrue(Double.isNaN(w.imaginary));
+ }
+
+ public void testAddInfinite() {
+ Complex x = new Complex(1, 1);
+ Complex z = new Complex(inf, 0);
+ Complex w = x.add(z);
+ assertEquals(w.imaginary, 1, 0);
+ assertEquals(inf, w.real, 0);
+
+ x = new Complex(neginf, 0);
+ assertTrue(Double.isNaN(x.add(z).real));
}
public void testConjugate() {
@@ -75,6 +111,13 @@
assertTrue(z.isNaN());
}
+ public void testConjugateInfiinite() {
+ Complex z = new Complex(0, inf);
+ assertEquals(neginf, z.conjugate().imaginary, 0);
+ z = new Complex(0, neginf);
+ assertEquals(inf, z.conjugate().imaginary, 0);
+ }
+
public void testDivide() {
Complex x = new Complex(3.0, 4.0);
Complex y = new Complex(5.0, 6.0);
@@ -83,12 +126,46 @@
assertEquals(2.0 / 61.0, z.getImaginary(), 1.0e-5);
}
+ public void testDivideInfinite() {
+ Complex x = new Complex(3, 4);
+ Complex w = new Complex(neginf, inf);
+ assertTrue(x.divide(w).equals(Complex.ZERO));
+
+ Complex z = w.divide(x);
+ assertTrue(Double.isNaN(z.real));
+ assertEquals(inf, z.imaginary, 0);
+
+ w = new Complex(inf, inf);
+ z = w.divide(x);
+ assertTrue(Double.isNaN(z.imaginary));
+ assertEquals(inf, z.real, 0);
+
+ w = new Complex(1, inf);
+ z = w.divide(w);
+ assertTrue(Double.isNaN(z.real));
+ assertTrue(Double.isNaN(z.imaginary));
+ }
+
public void testDivideNaN() {
Complex x = new Complex(3.0, 4.0);
Complex z = x.divide(Complex.NaN);
assertTrue(z.isNaN());
}
+ public void testDivideNaNInf() {
+ Complex z = oneInf.divide(Complex.ONE);
+ assertTrue(Double.isNaN(z.real));
+ assertEquals(inf, z.imaginary, 0);
+
+ z = negInfNegInf.divide(oneNaN);
+ assertTrue(Double.isNaN(z.real));
+ assertTrue(Double.isNaN(z.imaginary));
+
+ z = negInfInf.divide(Complex.ONE);
+ assertTrue(Double.isNaN(z.real));
+ assertTrue(Double.isNaN(z.imaginary));
+ }
+
public void testMultiply() {
Complex x = new Complex(3.0, 4.0);
Complex y = new Complex(5.0, 6.0);
@@ -101,6 +178,21 @@
Complex x = new Complex(3.0, 4.0);
Complex z = x.multiply(Complex.NaN);
assertTrue(z.isNaN());
+ }
+
+ public void testMultiplyNaNInf() {
+ Complex z = new Complex(1,1);
+ Complex w = z.multiply(infOne);
+ assertEquals(w.real, inf, 0);
+ assertEquals(w.imaginary, inf, 0);
+
+ w = oneInf.multiply(oneNegInf);
+ assertEquals(w.real, inf, 0);
+ assertTrue(Double.isNaN(w.imaginary));
+
+ w = negInfNegInf.multiply(oneNaN);
+ assertTrue(Double.isNaN(w.real));
+ assertTrue(Double.isNaN(w.imaginary));
}
public void testNegate() {
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexUtilsTest.java Thu Dec 22 13:16:32 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,16 +25,65 @@
*/
public class ComplexUtilsTest extends TestCase {
+ private double inf = Double.POSITIVE_INFINITY;
+ private double negInf = Double.NEGATIVE_INFINITY;
+ private double nan = Double.NaN;
+ private double pi = Math.PI;
+
+ private Complex oneInf = new Complex(1, inf);
+ private Complex oneNegInf = new Complex(1, negInf);
+ private Complex infOne = new Complex(inf, 1);
+ private Complex negInfOne = new Complex(negInf, 1);
+ private Complex negInfInf = new Complex(negInf, inf);
+ private Complex infNegInf = new Complex(inf, negInf);
+ private Complex infInf = new Complex(inf, inf);
+ private Complex negInfNegInf = new Complex(negInf, negInf);
+ private Complex oneNaN = new Complex(1, nan);
+ private Complex infNaN = new Complex(inf, nan);
+ private Complex negInfNaN = new Complex(negInf, nan);
+ private Complex nanInf = new Complex(nan, inf);
+ private Complex nanNegInf = new Complex(nan, negInf);
+ private Complex zeroNaN = new Complex(0, nan);
+ private Complex nanZero = new Complex(nan, 0);
+ private Complex infZero = new Complex(inf, 0);
+ private Complex zeroInf = new Complex(0, inf);
+ private Complex zeroNegInf = new Complex(0, negInf);
+ private Complex negInfZero = new Complex(negInf, 0);
+
+ private ComplexFormat fmt = new ComplexFormat();
+
public void testAcos() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(0.936812, -2.30551);
TestUtils.assertEquals(expected, ComplexUtils.acos(z), 1.0e-5);
+ TestUtils.assertEquals(new Complex(Math.acos(0), 0),
+ ComplexUtils.acos(Complex.ZERO), 1.0e-12);
+ }
+
+ public void testAcosInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(oneNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(infOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.acos(negInfNegInf));
}
public void testAcosNaN() {
assertTrue(ComplexUtils.acos(Complex.NaN).isNaN());
}
+ public void testAcosNull() {
+ try {
+ Complex z = ComplexUtils.acos(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testAsin() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(0.633984, 2.30551);
@@ -45,14 +94,55 @@
assertTrue(ComplexUtils.asin(Complex.NaN).isNaN());
}
+ public void testAsinInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(oneNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(infOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.asin(negInfNegInf));
+ }
+
+ public void testAsinNull() {
+ try {
+ Complex z = ComplexUtils.asin(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testAtan() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(1.44831, 0.158997);
TestUtils.assertEquals(expected, ComplexUtils.atan(z), 1.0e-5);
}
+ public void testAtanInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(oneNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(infOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.atan(negInfNegInf));
+ }
+
public void testAtanNaN() {
assertTrue(ComplexUtils.atan(Complex.NaN).isNaN());
+ assertTrue(ComplexUtils.atan(Complex.I).isNaN());
+ }
+
+ public void testAtanNull() {
+ try {
+ Complex z = ComplexUtils.atan(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
}
public void testCos() {
@@ -61,6 +151,30 @@
TestUtils.assertEquals(expected, ComplexUtils.cos(z), 1.0e-5);
}
+ public void testCosNaN() {
+ assertTrue(ComplexUtils.cos(Complex.NaN).isNaN());
+ }
+
+ public void testCosInf() {
+ TestUtils.assertSame(infNegInf, ComplexUtils.cos(oneInf));
+ TestUtils.assertSame(infInf, ComplexUtils.cos(oneNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cos(infOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cos(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cos(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cos(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cos(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cos(negInfNegInf));
+ }
+
+ public void testCosNull() {
+ try {
+ Complex z = ComplexUtils.cos(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testCosh() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(-6.58066, -7.58155);
@@ -71,20 +185,61 @@
assertTrue(ComplexUtils.cosh(Complex.NaN).isNaN());
}
- public void testCosNaN() {
- assertTrue(ComplexUtils.cos(Complex.NaN).isNaN());
+ public void testCoshInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cosh(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cosh(oneNegInf));
+ TestUtils.assertSame(infInf, ComplexUtils.cosh(infOne));
+ TestUtils.assertSame(infNegInf, ComplexUtils.cosh(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cosh(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cosh(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cosh(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.cosh(negInfNegInf));
+ }
+
+ public void testCoshNull() {
+ try {
+ Complex z = ComplexUtils.cosh(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
}
public void testExp() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(-13.12878, -15.20078);
TestUtils.assertEquals(expected, ComplexUtils.exp(z), 1.0e-5);
+ TestUtils.assertEquals(Complex.ONE,
+ ComplexUtils.exp(Complex.ZERO), 10e-12);
+ Complex iPi = Complex.I.multiply(new Complex(pi,0));
+ TestUtils.assertEquals(Complex.ONE.negate(),
+ ComplexUtils.exp(iPi), 10e-12);
}
public void testExpNaN() {
assertTrue(ComplexUtils.exp(Complex.NaN).isNaN());
}
+ public void testExpInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.exp(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.exp(oneNegInf));
+ TestUtils.assertSame(infInf, ComplexUtils.exp(infOne));
+ TestUtils.assertSame(Complex.ZERO, ComplexUtils.exp(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.exp(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.exp(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.exp(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.exp(negInfNegInf));
+ }
+
+ public void testExpNull() {
+ try {
+ Complex z = ComplexUtils.exp(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testLog() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(1.60944, 0.927295);
@@ -95,6 +250,101 @@
assertTrue(ComplexUtils.log(Complex.NaN).isNaN());
}
+ public void testLogInf() {
+ TestUtils.assertEquals(new Complex(inf, pi / 2),
+ ComplexUtils.log(oneInf), 10e-12);
+ TestUtils.assertEquals(new Complex(inf, -pi / 2),
+ ComplexUtils.log(oneNegInf), 10e-12);
+ TestUtils.assertEquals(infZero, ComplexUtils.log(infOne), 10e-12);
+ TestUtils.assertEquals(new Complex(inf, pi),
+ ComplexUtils.log(negInfOne), 10e-12);
+ TestUtils.assertEquals(new Complex(inf, pi / 4),
+ ComplexUtils.log(infInf), 10e-12);
+ TestUtils.assertEquals(new Complex(inf, -pi / 4),
+ ComplexUtils.log(infNegInf), 10e-12);
+ TestUtils.assertEquals(new Complex(inf, 3d * pi / 4),
+ ComplexUtils.log(negInfInf), 10e-12);
+ TestUtils.assertEquals(new Complex(inf, - 3d * pi / 4),
+ ComplexUtils.log(negInfNegInf), 10e-12);
+ }
+
+ public void testLogZero() {
+ TestUtils.assertSame(negInfZero, ComplexUtils.log(Complex.ZERO));
+ }
+
+ public void testlogNull() {
+ try {
+ Complex z = ComplexUtils.log(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
+ public void testPolar2Complex() {
+ TestUtils.assertEquals(Complex.ONE,
+ ComplexUtils.polar2Complex(1, 0), 10e-12);
+ TestUtils.assertEquals(Complex.ZERO,
+ ComplexUtils.polar2Complex(0, 1), 10e-12);
+ TestUtils.assertEquals(Complex.ZERO,
+ ComplexUtils.polar2Complex(0, -1), 10e-12);
+ TestUtils.assertEquals(Complex.I,
+ ComplexUtils.polar2Complex(1, pi/2), 10e-12);
+ TestUtils.assertEquals(Complex.I.negate(),
+ ComplexUtils.polar2Complex(1, -pi/2), 10e-12);
+ double r = 0;
+ for (int i = 0; i < 5; i++) {
+ r += i;
+ double theta = 0;
+ for (int j =0; j < 20; j++) {
+ theta += pi / 6;
+ TestUtils.assertEquals(altPolar(r, theta),
+ ComplexUtils.polar2Complex(r, theta), 10e-12);
+ }
+ theta = -2 * pi;
+ for (int j =0; j < 20; j++) {
+ theta -= pi / 6;
+ TestUtils.assertEquals(altPolar(r, theta),
+ ComplexUtils.polar2Complex(r, theta), 10e-12);
+ }
+ }
+ }
+
+ protected Complex altPolar(double r, double theta) {
+ return ComplexUtils.exp(Complex.I.multiply
+ (new Complex(theta, 0))).multiply(new Complex(r, 0));
+ }
+
+ public void testPolar2ComplexIllegalModulus() {
+ try {
+ Complex z = ComplexUtils.polar2Complex(-1, 0);
+ fail("Expecting IllegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ // expected
+ }
+ }
+
+ public void testPolar2ComplexNaN() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.polar2Complex(nan, 1));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.polar2Complex(1, nan));
+ TestUtils.assertSame(Complex.NaN,
+ ComplexUtils.polar2Complex(nan, nan));
+ }
+
+ public void testPolar2ComplexInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.polar2Complex(1, inf));
+ TestUtils.assertSame(Complex.NaN,
+ ComplexUtils.polar2Complex(1, negInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.polar2Complex(inf, inf));
+ TestUtils.assertSame(Complex.NaN,
+ ComplexUtils.polar2Complex(inf, negInf));
+ TestUtils.assertSame(infInf, ComplexUtils.polar2Complex(inf, pi/4));
+ TestUtils.assertSame(infNaN, ComplexUtils.polar2Complex(inf, 0));
+ TestUtils.assertSame(infNegInf, ComplexUtils.polar2Complex(inf, -pi/4));
+ TestUtils.assertSame(negInfInf, ComplexUtils.polar2Complex(inf, 3*pi/4));
+ TestUtils.assertSame(negInfNegInf, ComplexUtils.polar2Complex(inf, 5*pi/4));
+ }
+
public void testPow() {
Complex x = new Complex(3, 4);
Complex y = new Complex(5, 6);
@@ -112,12 +362,91 @@
assertTrue(ComplexUtils.pow(x, Complex.NaN).isNaN());
}
+ public void testPowInf() {
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, oneInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, oneNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, infOne));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, infInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, infNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, negInfInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(Complex.ONE, negInfNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infOne, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(negInfOne, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infInf, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infNegInf, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(negInfInf, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(negInfNegInf, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(negInfNegInf, infNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(negInfNegInf, negInfNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(negInfNegInf, infInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infInf, infNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infInf, negInfNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infInf, infInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infNegInf, infNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infNegInf, negInfNegInf));
+ TestUtils.assertSame(Complex.NaN,ComplexUtils.pow(infNegInf, infInf));
+ }
+
+ public void testPowZero() {
+ TestUtils.assertSame(Complex.NaN,
+ ComplexUtils.pow(Complex.ZERO, Complex.ONE));
+ TestUtils.assertSame(Complex.NaN,
+ ComplexUtils.pow(Complex.ZERO, Complex.ZERO));
+ TestUtils.assertSame(Complex.NaN,
+ ComplexUtils.pow(Complex.ZERO, Complex.I));
+ TestUtils.assertEquals(Complex.ONE,
+ ComplexUtils.pow(Complex.ONE, Complex.ZERO), 10e-12);
+ TestUtils.assertEquals(Complex.ONE,
+ ComplexUtils.pow(Complex.I, Complex.ZERO), 10e-12);
+ TestUtils.assertEquals(Complex.ONE,
+ ComplexUtils.pow(new Complex(-1, 3), Complex.ZERO), 10e-12);
+ }
+
+ public void testpowNull() {
+ try {
+ Complex z = ComplexUtils.pow(null, Complex.ONE);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ try {
+ Complex z = ComplexUtils.pow(Complex.ONE, null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testSin() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(3.853738, -27.01681);
TestUtils.assertEquals(expected, ComplexUtils.sin(z), 1.0e-5);
}
+ public void testSinInf() {
+ TestUtils.assertSame(infInf, ComplexUtils.sin(oneInf));
+ TestUtils.assertSame(infNegInf, ComplexUtils.sin(oneNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sin(infOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sin(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sin(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sin(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sin(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sin(negInfNegInf));
+ }
+
+ public void testSinNaN() {
+ assertTrue(ComplexUtils.sin(Complex.NaN).isNaN());
+ }
+
+ public void testSinNull() {
+ try {
+ Complex z = ComplexUtils.sin(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testSinh() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(-6.54812, -7.61923);
@@ -128,8 +457,24 @@
assertTrue(ComplexUtils.sinh(Complex.NaN).isNaN());
}
- public void testSinNaN() {
- assertTrue(ComplexUtils.sin(Complex.NaN).isNaN());
+ public void testSinhInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sinh(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sinh(oneNegInf));
+ TestUtils.assertSame(infInf, ComplexUtils.sinh(infOne));
+ TestUtils.assertSame(negInfInf, ComplexUtils.sinh(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sinh(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sinh(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sinh(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.sinh(negInfNegInf));
+ }
+
+ public void testsinhNull() {
+ try {
+ Complex z = ComplexUtils.sinh(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
}
public void testSqrtRealPositive() {
@@ -161,6 +506,44 @@
Complex expected = new Complex(1.0, -2.0);
TestUtils.assertEquals(expected, ComplexUtils.sqrt(z), 1.0e-5);
}
+
+ public void testSqrtPolar() {
+ double r = 1;
+ for (int i = 0; i < 5; i++) {
+ r += i;
+ double theta = 0;
+ for (int j =0; j < 11; j++) {
+ theta += pi /12;
+ Complex z = ComplexUtils.polar2Complex(r, theta);
+ Complex sqrtz = ComplexUtils.polar2Complex(Math.sqrt(r), theta / 2);
+ TestUtils.assertEquals(sqrtz, ComplexUtils.sqrt(z), 10e-12);
+ }
+ }
+ }
+
+ public void testSqrtNaN() {
+ assertTrue(ComplexUtils.sqrt(Complex.NaN).isNaN());
+ }
+
+ public void testSqrtInf() {
+ TestUtils.assertSame(infNaN, ComplexUtils.sqrt(oneInf));
+ TestUtils.assertSame(infNaN, ComplexUtils.sqrt(oneNegInf));
+ TestUtils.assertSame(infZero, ComplexUtils.sqrt(infOne));
+ TestUtils.assertSame(zeroInf, ComplexUtils.sqrt(negInfOne));
+ TestUtils.assertSame(infNaN, ComplexUtils.sqrt(infInf));
+ TestUtils.assertSame(infNaN, ComplexUtils.sqrt(infNegInf));
+ TestUtils.assertSame(nanInf, ComplexUtils.sqrt(negInfInf));
+ TestUtils.assertSame(nanNegInf, ComplexUtils.sqrt(negInfNegInf));
+ }
+
+ public void testSqrtNull() {
+ try {
+ Complex z = ComplexUtils.sqrt(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
public void testSqrt1z() {
Complex z = new Complex(3, 4);
@@ -172,8 +555,13 @@
assertTrue(ComplexUtils.sqrt1z(Complex.NaN).isNaN());
}
- public void testSqrtNaN() {
- assertTrue(ComplexUtils.sqrt(Complex.NaN).isNaN());
+ public void testSqrt1zNull() {
+ try {
+ Complex z = ComplexUtils.sqrt1z(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
}
public void testTan() {
@@ -182,6 +570,35 @@
TestUtils.assertEquals(expected, ComplexUtils.tan(z), 1.0e-5);
}
+ public void testTanNaN() {
+ assertTrue(ComplexUtils.tan(Complex.NaN).isNaN());
+ }
+
+ public void testTanInf() {
+ TestUtils.assertSame(zeroNaN, ComplexUtils.tan(oneInf));
+ TestUtils.assertSame(zeroNaN, ComplexUtils.tan(oneNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tan(infOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tan(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tan(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tan(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tan(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tan(negInfNegInf));
+ }
+
+ public void testTanCritical() {
+ TestUtils.assertSame(infNaN, ComplexUtils.tan(new Complex(pi/2, 0)));
+ TestUtils.assertSame(negInfNaN, ComplexUtils.tan(new Complex(-pi/2, 0)));
+ }
+
+ public void testTanNull() {
+ try {
+ Complex z = ComplexUtils.tan(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
+ }
+
public void testTanh() {
Complex z = new Complex(3, 4);
Complex expected = new Complex(1.00071, 0.00490826);
@@ -192,7 +609,27 @@
assertTrue(ComplexUtils.tanh(Complex.NaN).isNaN());
}
- public void testTanNaN() {
- assertTrue(ComplexUtils.tan(Complex.NaN).isNaN());
+ public void testTanhInf() {
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tanh(oneInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tanh(oneNegInf));
+ TestUtils.assertSame(nanZero, ComplexUtils.tanh(infOne));
+ TestUtils.assertSame(nanZero, ComplexUtils.tanh(negInfOne));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tanh(infInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tanh(infNegInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tanh(negInfInf));
+ TestUtils.assertSame(Complex.NaN, ComplexUtils.tanh(negInfNegInf));
+ }
+
+ public void testTanhCritical() {
+ TestUtils.assertSame(nanInf, ComplexUtils.tanh(new Complex(0, pi/2)));
+ }
+
+ public void testTanhNull() {
+ try {
+ Complex z = ComplexUtils.tanh(null);
+ fail("Expecting NullPointerException");
+ } catch (NullPointerException ex) {
+ // expected
+ }
}
}
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/HypergeometricDistributionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/HypergeometricDistributionTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/HypergeometricDistributionTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/HypergeometricDistributionTest.java Thu Dec 22 13:16:32 2005
@@ -132,17 +132,17 @@
}
public void testLargeValues() {
- int populationSize = 3456;
- int sampleSize = 789;
- int numberOfSucceses = 101;
- double[][] data = {
- {0.0, 2.75646034603961e-12, 2.75646034603961e-12, 1.0},
- {1.0, 8.55705370142386e-11, 8.83269973602783e-11, 0.999999999997244},
- {2.0, 1.31288129219665e-9, 1.40120828955693e-9, 0.999999999911673},
- {3.0, 1.32724172984193e-8, 1.46736255879763e-8, 0.999999998598792},
- {4.0, 9.94501711734089e-8, 1.14123796761385e-7, 0.999999985326375},
- {5.0, 5.89080768883643e-7, 7.03204565645028e-7, 0.999999885876203},
- {20.0, 0.0760051397707708, 0.27349758476299, 0.802507555007781},
+ int populationSize = 3456;
+ int sampleSize = 789;
+ int numberOfSucceses = 101;
+ double[][] data = {
+ {0.0, 2.75646034603961e-12, 2.75646034603961e-12, 1.0},
+ {1.0, 8.55705370142386e-11, 8.83269973602783e-11, 0.999999999997244},
+ {2.0, 1.31288129219665e-9, 1.40120828955693e-9, 0.999999999911673},
+ {3.0, 1.32724172984193e-8, 1.46736255879763e-8, 0.999999998598792},
+ {4.0, 9.94501711734089e-8, 1.14123796761385e-7, 0.999999985326375},
+ {5.0, 5.89080768883643e-7, 7.03204565645028e-7, 0.999999885876203},
+ {20.0, 0.0760051397707708, 0.27349758476299, 0.802507555007781},
{21.0, 0.087144222047629, 0.360641806810619, 0.72650241523701},
{22.0, 0.0940378846881819, 0.454679691498801, 0.639358193189381},
{23.0, 0.0956897500614809, 0.550369441560282, 0.545320308501199},
@@ -154,40 +154,40 @@
{99.0, 6.63604297068222e-63, 1.0, 6.670480942963e-63},
{100.0, 3.43501099007557e-65, 1.0, 3.4437972280786e-65},
{101.0, 8.78623800302957e-68, 1.0, 8.78623800302957e-68},
- };
+ };
- testHypergeometricDistributionProbabilities(populationSize, sampleSize, numberOfSucceses, data);
+ testHypergeometricDistributionProbabilities(populationSize, sampleSize, numberOfSucceses, data);
}
- private void testHypergeometricDistributionProbabilities(int populationSize, int sampleSize, int numberOfSucceses, double[][] data) {
- HypergeometricDistributionImpl dist = new HypergeometricDistributionImpl(populationSize, numberOfSucceses, sampleSize);
- for (int i = 0; i < data.length; ++i) {
- int x = (int)data[i][0];
- double pdf = data[i][1];
- double actualPdf = dist.probability(x);
- TestUtils.assertRelativelyEquals(pdf, actualPdf, 1.0e-9);
+ private void testHypergeometricDistributionProbabilities(int populationSize, int sampleSize, int numberOfSucceses, double[][] data) {
+ HypergeometricDistributionImpl dist = new HypergeometricDistributionImpl(populationSize, numberOfSucceses, sampleSize);
+ for (int i = 0; i < data.length; ++i) {
+ int x = (int)data[i][0];
+ double pdf = data[i][1];
+ double actualPdf = dist.probability(x);
+ TestUtils.assertRelativelyEquals(pdf, actualPdf, 1.0e-9);
- double cdf = data[i][2];
- double actualCdf = dist.cumulativeProbability(x);
- TestUtils.assertRelativelyEquals(cdf, actualCdf, 1.0e-9);
+ double cdf = data[i][2];
+ double actualCdf = dist.cumulativeProbability(x);
+ TestUtils.assertRelativelyEquals(cdf, actualCdf, 1.0e-9);
- double cdf1 = data[i][3];
- double actualCdf1 = dist.upperCumulativeProbability(x);
- TestUtils.assertRelativelyEquals(cdf1, actualCdf1, 1.0e-9);
- }
- }
+ double cdf1 = data[i][3];
+ double actualCdf1 = dist.upperCumulativeProbability(x);
+ TestUtils.assertRelativelyEquals(cdf1, actualCdf1, 1.0e-9);
+ }
+ }
public void testMoreLargeValues() {
- int populationSize = 26896;
- int sampleSize = 895;
- int numberOfSucceses = 55;
- double[][] data = {
- {0.0, 0.155168304750504, 0.155168304750504, 1.0},
+ int populationSize = 26896;
+ int sampleSize = 895;
+ int numberOfSucceses = 55;
+ double[][] data = {
+ {0.0, 0.155168304750504, 0.155168304750504, 1.0},
{1.0, 0.29437545000746, 0.449543754757964, 0.844831695249496},
- {2.0, 0.273841321577003, 0.723385076334967, 0.550456245242036},
- {3.0, 0.166488572570786, 0.889873648905753, 0.276614923665033},
- {4.0, 0.0743969744713231, 0.964270623377076, 0.110126351094247},
- {5.0, 0.0260542785784855, 0.990324901955562, 0.0357293766229237},
+ {2.0, 0.273841321577003, 0.723385076334967, 0.550456245242036},
+ {3.0, 0.166488572570786, 0.889873648905753, 0.276614923665033},
+ {4.0, 0.0743969744713231, 0.964270623377076, 0.110126351094247},
+ {5.0, 0.0260542785784855, 0.990324901955562, 0.0357293766229237},
{20.0, 3.57101101678792e-16, 1.0, 3.78252101622096e-16},
{21.0, 2.00551638598312e-17, 1.0, 2.11509999433041e-17},
{22.0, 1.04317070180562e-18, 1.0, 1.09583608347287e-18},
@@ -200,7 +200,7 @@
{53.0, 1.43662126065532e-76, 1.0, 1.43834540093295e-76},
{54.0, 1.72312692517348e-79, 1.0, 1.7241402776278e-79},
{55.0, 1.01335245432581e-82, 1.0, 1.01335245432581e-82},
- };
- testHypergeometricDistributionProbabilities(populationSize, sampleSize, numberOfSucceses, data);
+ };
+ testHypergeometricDistributionProbabilities(populationSize, sampleSize, numberOfSucceses, data);
}
}
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/PoissonDistributionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/PoissonDistributionTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/PoissonDistributionTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/distribution/PoissonDistributionTest.java Thu Dec 22 13:16:32 2005
@@ -137,44 +137,44 @@
}
public void testLargeMeanCumulativeProbability() {
- PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(1.0);
- double mean = 1.0;
- while (mean <= 10000000.0) {
- dist.setMean(mean);
-
- double x = mean * 2.0;
- double dx = x / 10.0;
- while (x >= 0) {
- try {
- dist.cumulativeProbability(x);
- } catch (MathException ex) {
- fail("mean of " + mean + " and x of " + x + " caused " + ex.getMessage());
- }
- x -= dx;
- }
-
- mean *= 10.0;
- }
+ PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(1.0);
+ double mean = 1.0;
+ while (mean <= 10000000.0) {
+ dist.setMean(mean);
+
+ double x = mean * 2.0;
+ double dx = x / 10.0;
+ while (x >= 0) {
+ try {
+ dist.cumulativeProbability(x);
+ } catch (MathException ex) {
+ fail("mean of " + mean + " and x of " + x + " caused " + ex.getMessage());
+ }
+ x -= dx;
+ }
+
+ mean *= 10.0;
+ }
}
public void testLargeMeanInverseCumulativeProbability() {
- PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(1.0);
- double mean = 1.0;
- while (mean <= 10000000.0) {
- dist.setMean(mean);
-
- double p = 0.1;
- double dp = p;
- while (p < 1.0) {
- try {
- dist.inverseCumulativeProbability(p);
- } catch (MathException ex) {
- fail("mean of " + mean + " and p of " + p + " caused " + ex.getMessage());
- }
- p += dp;
- }
-
- mean *= 10.0;
- }
+ PoissonDistribution dist = DistributionFactory.newInstance().createPoissonDistribution(1.0);
+ double mean = 1.0;
+ while (mean <= 10000000.0) {
+ dist.setMean(mean);
+
+ double p = 0.1;
+ double dp = p;
+ while (p < 1.0) {
+ try {
+ dist.inverseCumulativeProbability(p);
+ } catch (MathException ex) {
+ fail("mean of " + mean + " and p of " + p + " caused " + ex.getMessage());
+ }
+ p += dp;
+ }
+
+ mean *= 10.0;
+ }
}
}
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java Thu Dec 22 13:16:32 2005
@@ -115,6 +115,11 @@
assertEquals
(empiricalDistribution2.getSampleStats().getStandardDeviation(),
1.0173699343977738,10E-7);
+
+ double[] bounds = empiricalDistribution2.getUpperBounds();
+ assertEquals(bounds.length, 100);
+ assertEquals(bounds[99], 1.0, 10e-12);
+
}
/**
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/RandomDataTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/RandomDataTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/RandomDataTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/random/RandomDataTest.java Thu Dec 22 13:16:32 2005
@@ -420,13 +420,19 @@
/* remove this test back soon,
* since it takes about 4 seconds */
-
- randomData.setSecureAlgorithm("SHA1PRNG","SUN");
+
+ try {
+ randomData.setSecureAlgorithm("SHA1PRNG","SUN");
+ } catch (NoSuchProviderException ex) {
+ ;
+ }
assertTrue("different seeds",
!hex.equals(randomData.nextSecureHexString(40)));
try {
randomData.setSecureAlgorithm("NOSUCHTHING","SUN");
fail("expecting NoSuchAlgorithmException");
+ } catch (NoSuchProviderException ex) {
+ ;
} catch (NoSuchAlgorithmException ex) {
;
}
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/StatUtilsTest.java Thu Dec 22 13:16:32 2005
@@ -411,7 +411,7 @@
// expected
}
try {
- double[] single = {1.0};
+ double[] single = {1.0};
StatUtils.varianceDifference(single, single, meanDifference);
fail("Expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
Modified: jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java?rev=358631&r1=358630&r2=358631&view=diff
==============================================================================
--- jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java (original)
+++ jakarta/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java Thu Dec 22 13:16:32 2005
@@ -31,7 +31,7 @@
public class ListUnivariateImpl extends DescriptiveStatistics implements Serializable {
/** Serializable version identifier */
- static final long serialVersionUID = -8837442489133392138L;
+ private static final long serialVersionUID = -8837442489133392138L;
/**
* Holds a reference to a list - GENERICs are going to make
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org