[
https://issues.apache.org/jira/browse/MATH-623?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Arne Plöse updated MATH-623:
----------------------------
Attachment: ArrayRealVector.diff
here the changes for any *(double[] v) methods.
Why not change
{code}
public RealVector add(RealVector v) {...}
{code}
to this:
{code}
@Override
public RealVector add(RealVector v) {
if (v instanceof ArrayRealVector) {
return add(((ArrayRealVector) v).data);
} else {
checkVectorDimensions(v);
double[] out = data.clone();
Iterator<Entry> it = v.sparseIterator();
Entry e;
while (it.hasNext() && (e = it.next()) != null) {
out[e.getIndex()] += e.getValue();
}
return new ArrayRealVector(out, false);
}
}
{code}
and drop
{code}
public ArrayRealVector add(ArrayRealVector v) {...}
{code}
it only exposes the implementation of RealVector and I think the compiler knows
seldom of ArrayRealvector as argument...
By the way there is no need for /** {@inheritDoc} */ on methods with @Override
annotation, maybe remove this commnet in this case?
Stupid question dou you want a new issue for all of these?
> Use implementation of JAMA for ArrayRealVector operators
> --------------------------------------------------------
>
> Key: MATH-623
> URL: https://issues.apache.org/jira/browse/MATH-623
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 3.0
> Reporter: Arne Plöse
> Priority: Minor
> Attachments: ArrayRealVector.diff, ArrayRealVector.diff
>
>
> For instance the add(double[] v) fist clones the array, and then adds all
> entries of this.data to the result.
> JAMA uses the following approach create a empty result[] the assign the sum
> of each entry to the result. this is approximately 10 -20 % faster.
> I will provide a patch with some more enhancements/cleanups for this.
> in the test look for XXX:
> the first number is the jama time the second the current algorithm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira