Sébastien Brisard created MATH-802:
--------------------------------------
Summary: RealVector.subtract(RealVector) returns wrong answer.
Key: MATH-802
URL: https://issues.apache.org/jira/browse/MATH-802
Project: Commons Math
Issue Type: Bug
Affects Versions: 3.0
Reporter: Sébastien Brisard
Assignee: Sébastien Brisard
Fix For: 3.1
The following piece of code
{code:java}
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.OpenMapRealVector;
import org.apache.commons.math3.linear.RealVectorFormat;
public class DemoMath {
public static void main(String[] args) {
final double[] data1 = {
0d, 1d, 0d, 0d, 2d
};
final double[] data2 = {
3d, 0d, 4d, 0d, 5d
};
final RealVectorFormat format = new RealVectorFormat();
System.out.println(format.format(new ArrayRealVector(data1)
.subtract(new ArrayRealVector(data2))));
System.out.println(format.format(new OpenMapRealVector(data1)
.subtract(new ArrayRealVector(data2))));
}
}
{code}
prints
{noformat}
{-3; 1; -4; 0; -3}
{3; 1; 4; 0; -3}
{noformat}
the second line being wrong. In fact, when subtracting mixed types,
{{OpenMapRealVector}} delegates to the default implementation in {{RealVector}}
which is buggy.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira