MATH-623
Slightly faster "add" method (due to Arne Plöse). git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1148952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d0c461e6e
commit
7133fb43b7
|
@ -304,12 +304,14 @@ public class ArrayRealVector extends AbstractRealVector implements Serializable
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public RealVector add(double[] v) {
|
||||
checkVectorDimensions(v.length);
|
||||
double[] out = data.clone();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
out[i] += v[i];
|
||||
final int dim = v.length;
|
||||
checkVectorDimensions(dim);
|
||||
ArrayRealVector result = new ArrayRealVector(dim);
|
||||
double[] resultData = result.data;
|
||||
for (int i = 0; i < dim; i++) {
|
||||
resultData[i] = data[i] + v[i];
|
||||
}
|
||||
return new ArrayRealVector(out, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue