You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sébastien Brisard (JIRA)" <ji...@apache.org> on 2012/06/09 15:14:43 UTC
[jira] [Resolved] (MATH-802) RealVector.subtract(RealVector)
returns wrong answer.
[ https://issues.apache.org/jira/browse/MATH-802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sébastien Brisard resolved MATH-802.
------------------------------------
Resolution: Fixed
> 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