MATH-387: Allow "null" array arguments in "RealPointValuePair" and
"VectorialPointValuePair" constructors. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@965509 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
968c4a2cf4
commit
730e17083e
|
@ -29,7 +29,6 @@ import java.io.Serializable;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class RealPointValuePair implements Serializable {
|
public class RealPointValuePair implements Serializable {
|
||||||
|
|
||||||
/** Serializable version identifier. */
|
/** Serializable version identifier. */
|
||||||
private static final long serialVersionUID = 1003888396256744753L;
|
private static final long serialVersionUID = 1003888396256744753L;
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ public class RealPointValuePair implements Serializable {
|
||||||
* @param value value of an objective function at the point
|
* @param value value of an objective function at the point
|
||||||
*/
|
*/
|
||||||
public RealPointValuePair(final double[] point, final double value) {
|
public RealPointValuePair(final double[] point, final double value) {
|
||||||
this.point = point.clone();
|
this.point = (point == null ? null : point.clone());
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +57,9 @@ public class RealPointValuePair implements Serializable {
|
||||||
*/
|
*/
|
||||||
public RealPointValuePair(final double[] point, final double value,
|
public RealPointValuePair(final double[] point, final double value,
|
||||||
final boolean copyArray) {
|
final boolean copyArray) {
|
||||||
this.point = copyArray ? point.clone() : point;
|
this.point = (copyArray ?
|
||||||
|
(point == null ? null : point.clone()) :
|
||||||
|
point);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ public class RealPointValuePair implements Serializable {
|
||||||
* @return a copy of the stored point
|
* @return a copy of the stored point
|
||||||
*/
|
*/
|
||||||
public double[] getPoint() {
|
public double[] getPoint() {
|
||||||
return point.clone();
|
return (point == null ? null : point.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a reference to the point.
|
/** Get a reference to the point.
|
||||||
|
@ -84,5 +85,4 @@ public class RealPointValuePair implements Serializable {
|
||||||
public double getValue() {
|
public double getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,5 +77,4 @@ public class SimpleScalarValueChecker implements RealConvergenceChecker {
|
||||||
final double size = Math.max(Math.abs(p), Math.abs(c));
|
final double size = Math.max(Math.abs(p), Math.abs(c));
|
||||||
return (difference <= (size * relativeThreshold)) || (difference <= absoluteThreshold);
|
return (difference <= (size * relativeThreshold)) || (difference <= absoluteThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class VectorialPointValuePair implements Serializable {
|
||||||
* @param value value of an objective function at the point
|
* @param value value of an objective function at the point
|
||||||
*/
|
*/
|
||||||
public VectorialPointValuePair(final double[] point, final double[] value) {
|
public VectorialPointValuePair(final double[] point, final double[] value) {
|
||||||
this.point = point.clone();
|
this.point = (point == null ? null : point.clone());
|
||||||
this.value = value.clone();
|
this.value = (value == null ? null : value.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build a point/objective function value pair.
|
/** Build a point/objective function value pair.
|
||||||
|
@ -57,15 +57,19 @@ public class VectorialPointValuePair implements Serializable {
|
||||||
*/
|
*/
|
||||||
public VectorialPointValuePair(final double[] point, final double[] value,
|
public VectorialPointValuePair(final double[] point, final double[] value,
|
||||||
final boolean copyArray) {
|
final boolean copyArray) {
|
||||||
this.point = copyArray ? point.clone() : point;
|
this.point = (copyArray ?
|
||||||
this.value = copyArray ? value.clone() : value;
|
(point == null ? null : point.clone()) :
|
||||||
|
point);
|
||||||
|
this.value = (copyArray ?
|
||||||
|
(value == null ? null : value.clone()) :
|
||||||
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the point.
|
/** Get the point.
|
||||||
* @return a copy of the stored point
|
* @return a copy of the stored point
|
||||||
*/
|
*/
|
||||||
public double[] getPoint() {
|
public double[] getPoint() {
|
||||||
return point.clone();
|
return (point == null ? null : point.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a reference to the point.
|
/** Get a reference to the point.
|
||||||
|
@ -81,7 +85,7 @@ public class VectorialPointValuePair implements Serializable {
|
||||||
* @return a copy of the stored value of the objective function
|
* @return a copy of the stored value of the objective function
|
||||||
*/
|
*/
|
||||||
public double[] getValue() {
|
public double[] getValue() {
|
||||||
return value.clone();
|
return (value == null ? null : value.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a reference to the value of the objective function.
|
/** Get a reference to the value of the objective function.
|
||||||
|
|
Loading…
Reference in New Issue