commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r965509 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization: RealPointValuePair.java SimpleScalarValueChecker.java VectorialPointValuePair.java
Date Mon, 19 Jul 2010 14:51:24 GMT
Author: erans
Date: Mon Jul 19 14:51:24 2010
New Revision: 965509

URL: http://svn.apache.org/viewvc?rev=965509&view=rev
Log:
MATH-387: Allow "null" array arguments in "RealPointValuePair" and
"VectorialPointValuePair" constructors.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/RealPointValuePair.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/VectorialPointValuePair.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/RealPointValuePair.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/RealPointValuePair.java?rev=965509&r1=965508&r2=965509&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/RealPointValuePair.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/RealPointValuePair.java
Mon Jul 19 14:51:24 2010
@@ -29,7 +29,6 @@ import java.io.Serializable;
  * @since 2.0
  */
 public class RealPointValuePair implements Serializable {
-
     /** Serializable version identifier. */
     private static final long serialVersionUID = 1003888396256744753L;
 
@@ -45,7 +44,7 @@ public class RealPointValuePair implemen
      * @param value value of an objective function at the point
      */
     public RealPointValuePair(final double[] point, final double value) {
-        this.point = point.clone();
+        this.point = (point == null ? null : point.clone());
         this.value  = value;
     }
 
@@ -57,8 +56,10 @@ public class RealPointValuePair implemen
      * it will be referenced
      */
     public RealPointValuePair(final double[] point, final double value,
-                                final boolean copyArray) {
-        this.point = copyArray ? point.clone() : point;
+                              final boolean copyArray) {
+        this.point = (copyArray ?
+                      (point == null ? null : point.clone()) :
+                      point);
         this.value  = value;
     }
 
@@ -66,7 +67,7 @@ public class RealPointValuePair implemen
      * @return a copy of the stored point
      */
     public double[] getPoint() {
-        return point.clone();
+        return (point == null ? null : point.clone());
     }
 
     /** Get a reference to the point.
@@ -84,5 +85,4 @@ public class RealPointValuePair implemen
     public double getValue() {
         return value;
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleScalarValueChecker.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleScalarValueChecker.java?rev=965509&r1=965508&r2=965509&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleScalarValueChecker.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/SimpleScalarValueChecker.java
Mon Jul 19 14:51:24 2010
@@ -62,7 +62,7 @@ public class SimpleScalarValueChecker im
      * @param absoluteThreshold absolute tolerance threshold
      */
     public SimpleScalarValueChecker(final double relativeThreshold,
-                                 final double absoluteThreshold) {
+                                    final double absoluteThreshold) {
         this.relativeThreshold = relativeThreshold;
         this.absoluteThreshold = absoluteThreshold;
     }
@@ -77,5 +77,4 @@ public class SimpleScalarValueChecker im
         final double size       = Math.max(Math.abs(p), Math.abs(c));
         return (difference <= (size * relativeThreshold)) || (difference <= absoluteThreshold);
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/VectorialPointValuePair.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/VectorialPointValuePair.java?rev=965509&r1=965508&r2=965509&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/VectorialPointValuePair.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/VectorialPointValuePair.java
Mon Jul 19 14:51:24 2010
@@ -44,8 +44,8 @@ public class VectorialPointValuePair imp
      * @param value value of an objective function at the point
      */
     public VectorialPointValuePair(final double[] point, final double[] value) {
-        this.point = point.clone();
-        this.value = value.clone();
+        this.point = (point == null ? null : point.clone());
+        this.value = (value == null ? null : value.clone());
     }
 
     /** Build a point/objective function value pair.
@@ -57,15 +57,19 @@ public class VectorialPointValuePair imp
      */
     public VectorialPointValuePair(final double[] point, final double[] value,
                                    final boolean copyArray) {
-        this.point = copyArray ? point.clone() : point;
-        this.value = copyArray ? value.clone() : value;
+        this.point = (copyArray ?
+                      (point == null ? null : point.clone()) :
+                      point);
+        this.value = (copyArray ?
+                      (value == null ? null : value.clone()) :
+                      value);
     }
 
     /** Get the point.
      * @return a copy of the stored point
      */
     public double[] getPoint() {
-        return point.clone();
+        return (point == null ? null : point.clone());
     }
 
     /** Get a reference to the point.
@@ -81,7 +85,7 @@ public class VectorialPointValuePair imp
      * @return a copy of the stored value of the objective function
      */
     public double[] getValue() {
-        return value.clone();
+        return (value == null ? null : value.clone());
     }
 
     /** Get a reference to the value of the objective function.



Mime
View raw message