Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F2B68908D for ; Sat, 9 Jun 2012 13:14:43 +0000 (UTC) Received: (qmail 76801 invoked by uid 500); 9 Jun 2012 13:14:43 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 76717 invoked by uid 500); 9 Jun 2012 13:14:43 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 76640 invoked by uid 99); 9 Jun 2012 13:14:43 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jun 2012 13:14:43 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 4E8B6142862 for ; Sat, 9 Jun 2012 13:14:43 +0000 (UTC) Date: Sat, 9 Jun 2012 13:14:43 +0000 (UTC) From: =?utf-8?Q?S=C3=A9bastien_Brisard_=28JIRA=29?= To: issues@commons.apache.org Message-ID: <340070819.268.1339247683323.JavaMail.jiratomcat@issues-vm> In-Reply-To: <594952805.258.1339247202923.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Resolved] (MATH-802) RealVector.subtract(RealVector) returns wrong answer. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-802?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:all-tabpanel ] S=C3=A9bastien Brisard resolved MATH-802. ------------------------------------ Resolution: Fixed =20 > 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=C3=A9bastien Brisard > Assignee: S=C3=A9bastien 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 =3D { > 0d, 1d, 0d, 0d, 2d > }; > final double[] data2 =3D { > 3d, 0d, 4d, 0d, 5d > }; > final RealVectorFormat format =3D 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, {{Ope= nMapRealVector}} 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 administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira