package com.srbenoit.math.optimizers;
/**
* A point in an N-dimensional space along with the value of a function at that point.
*/
public class PointAndValue {
/** the point coordinates */
private final transient double[] point;
/** the point value */
private final transient double value;
/**
* Constructs a new PointAndValue
.
*
* @param coordinates the point coordinates
* @param functionValue the function value
*/
public PointAndValue(final double[] coordinates, final double functionValue) {
this.point = coordinates.clone();
this.value = functionValue;
}
/**
* Get the point coordinates as an array.
*
* @return the point coordinates
*/
public double[] getPoint() {
return this.point.clone();
}
/**
* Get the value at the point.
*
* @return the value
*/
public double getValue() {
return this.value;
}
/**
* Generates the string representation of the point.
*
* @return the String
*/
@Override public String toString() {
StringBuilder str;
str = new StringBuilder(40);
str.append('(');
for (int i = 0; i < this.point.length; i++) {
if (i > 0) {
str.append(',');
}
str.append(Double.toString(this.point[i]));
}
str.append(") --> ");
str.append(Double.toString(this.value));
return str.toString();
}
}