本文整理汇总了Java中org.apache.commons.math3.optim.PointVectorValuePair.getValueRef方法的典型用法代码示例。如果您正苦于以下问题:Java PointVectorValuePair.getValueRef方法的具体用法?Java PointVectorValuePair.getValueRef怎么用?Java PointVectorValuePair.getValueRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.optim.PointVectorValuePair
的用法示例。
在下文中一共展示了PointVectorValuePair.getValueRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPairComparator
import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
/**
* @return a comparator for sorting the optima.
*/
private Comparator<PointVectorValuePair> getPairComparator() {
return new Comparator<PointVectorValuePair>() {
private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
private final RealMatrix weight = optimizer.getWeight();
public int compare(final PointVectorValuePair o1,
final PointVectorValuePair o2) {
if (o1 == null) {
return (o2 == null) ? 0 : 1;
} else if (o2 == null) {
return -1;
}
return Double.compare(weightedResidual(o1),
weightedResidual(o2));
}
private double weightedResidual(final PointVectorValuePair pv) {
final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
final RealVector r = target.subtract(v);
return r.dotProduct(weight.operate(r));
}
};
}
示例2: getPairComparator
import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
/**
* @return a comparator for sorting the optima.
*/
private Comparator<PointVectorValuePair> getPairComparator() {
return new Comparator<PointVectorValuePair>() {
/** Observed value to be matched. */
private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false);
/** Observations weights. */
private final RealMatrix weight = optimizer.getWeight();
/** {@inheritDoc} */
public int compare(final PointVectorValuePair o1,
final PointVectorValuePair o2) {
if (o1 == null) {
return (o2 == null) ? 0 : 1;
} else if (o2 == null) {
return -1;
}
return Double.compare(weightedResidual(o1),
weightedResidual(o2));
}
private double weightedResidual(final PointVectorValuePair pv) {
final RealVector v = new ArrayRealVector(pv.getValueRef(), false);
final RealVector r = target.subtract(v);
return r.dotProduct(weight.operate(r));
}
};
}