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 2008/04/24 14:02:03 UTC

svn commit: r651228 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/complex/Complex.java test/org/apache/commons/math/complex/ComplexTest.java

Author: luc
Date: Thu Apr 24 05:01:59 2008
New Revision: 651228

URL: http://svn.apache.org/viewvc?rev=651228&view=rev
Log:
replaced deprecated protected real/imaginary fields by private final fields

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/Complex.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/complex/ComplexTest.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/Complex.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/Complex.java?rev=651228&r1=651227&r2=651228&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/Complex.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/complex/Complex.java Thu Apr 24 05:01:59 2008
@@ -58,15 +58,13 @@
     
     /** 
      * The imaginary part 
-     * @deprecated to be made final and private in 2.0
      */
-    protected double imaginary;
+    private final double imaginary;
     
     /** 
      * The real part 
-     * @deprecated to be made final and private in 2.0
      */
-    protected double real;
+    private final double real;
     
     /**
      * Create a complex number given the real and imaginary parts.

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/complex/ComplexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/complex/ComplexTest.java?rev=651228&r1=651227&r2=651228&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/complex/ComplexTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/complex/ComplexTest.java Thu Apr 24 05:01:59 2008
@@ -100,19 +100,19 @@
         assertTrue(z.isNaN());
         z = new Complex(1, nan);
         Complex w = x.add(z);
-        assertEquals(w.real, 4.0, 0);
-        assertTrue(Double.isNaN(w.imaginary));
+        assertEquals(w.getReal(), 4.0, 0);
+        assertTrue(Double.isNaN(w.getImaginary()));
     }
     
     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);
+        assertEquals(w.getImaginary(), 1, 0);
+        assertEquals(inf, w.getReal(), 0);
         
         x = new Complex(neginf, 0);
-        assertTrue(Double.isNaN(x.add(z).real));
+        assertTrue(Double.isNaN(x.add(z).getReal()));
     }
     
     public void testConjugate() {
@@ -129,9 +129,9 @@
     
     public void testConjugateInfiinite() {
         Complex z = new Complex(0, inf);
-        assertEquals(neginf, z.conjugate().imaginary, 0);
+        assertEquals(neginf, z.conjugate().getImaginary(), 0);
         z = new Complex(0, neginf);
-        assertEquals(inf, z.conjugate().imaginary, 0);
+        assertEquals(inf, z.conjugate().getImaginary(), 0);
     }
     
     public void testDivide() {
@@ -148,18 +148,18 @@
         assertTrue(x.divide(w).equals(Complex.ZERO));
         
         Complex z = w.divide(x);
-        assertTrue(Double.isNaN(z.real));
-        assertEquals(inf, z.imaginary, 0);
+        assertTrue(Double.isNaN(z.getReal()));
+        assertEquals(inf, z.getImaginary(), 0);
         
         w = new Complex(inf, inf);
         z = w.divide(x);
-        assertTrue(Double.isNaN(z.imaginary));
-        assertEquals(inf, z.real, 0);
+        assertTrue(Double.isNaN(z.getImaginary()));
+        assertEquals(inf, z.getReal(), 0);
         
         w = new Complex(1, inf);
         z = w.divide(w);
-        assertTrue(Double.isNaN(z.real));
-        assertTrue(Double.isNaN(z.imaginary));
+        assertTrue(Double.isNaN(z.getReal()));
+        assertTrue(Double.isNaN(z.getImaginary()));
     }
     
     public void testDivideNaN() {
@@ -170,16 +170,16 @@
     
     public void testDivideNaNInf() {  
        Complex z = oneInf.divide(Complex.ONE);
-       assertTrue(Double.isNaN(z.real));
-       assertEquals(inf, z.imaginary, 0);
+       assertTrue(Double.isNaN(z.getReal()));
+       assertEquals(inf, z.getImaginary(), 0);
        
        z = negInfNegInf.divide(oneNaN);
-       assertTrue(Double.isNaN(z.real));
-       assertTrue(Double.isNaN(z.imaginary));
+       assertTrue(Double.isNaN(z.getReal()));
+       assertTrue(Double.isNaN(z.getImaginary()));
        
        z = negInfInf.divide(Complex.ONE);
-       assertTrue(Double.isNaN(z.real));
-       assertTrue(Double.isNaN(z.imaginary));
+       assertTrue(Double.isNaN(z.getReal()));
+       assertTrue(Double.isNaN(z.getImaginary()));
     }
     
     public void testMultiply() {
@@ -199,8 +199,8 @@
     public void testMultiplyNaNInf() {
         Complex z = new Complex(1,1);
         Complex w = z.multiply(infOne);
-        assertEquals(w.real, inf, 0);
-        assertEquals(w.imaginary, inf, 0);
+        assertEquals(w.getReal(), inf, 0);
+        assertEquals(w.getImaginary(), inf, 0);
 
         // [MATH-164]
         assertTrue(new Complex( 1,0).multiply(infInf).equals(Complex.INF));
@@ -208,12 +208,12 @@
         assertTrue(new Complex( 1,0).multiply(negInfZero).equals(Complex.INF));
         
         w = oneInf.multiply(oneNegInf);
-        assertEquals(w.real, inf, 0);
-        assertEquals(w.imaginary, inf, 0);
+        assertEquals(w.getReal(), inf, 0);
+        assertEquals(w.getImaginary(), inf, 0);
         
         w = negInfNegInf.multiply(oneNaN);
-        assertTrue(Double.isNaN(w.real));
-        assertTrue(Double.isNaN(w.imaginary));  
+        assertTrue(Double.isNaN(w.getReal()));
+        assertTrue(Double.isNaN(w.getImaginary()));  
     }
     
     public void testNegate() {