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 7FCB490F7 for ; Sat, 7 Jul 2012 12:30:36 +0000 (UTC) Received: (qmail 80814 invoked by uid 500); 7 Jul 2012 12:30:36 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 80743 invoked by uid 500); 7 Jul 2012 12:30:36 -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 80725 invoked by uid 99); 7 Jul 2012 12:30:35 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Jul 2012 12:30:35 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 46D59142851 for ; Sat, 7 Jul 2012 12:30:35 +0000 (UTC) Date: Sat, 7 Jul 2012 12:30:35 +0000 (UTC) From: "Gilles (JIRA)" To: issues@commons.apache.org Message-ID: <2136483494.18603.1341664235291.JavaMail.jiratomcat@issues-vm> In-Reply-To: <649986181.18558.1341662554499.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Commented] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators 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-812?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D134086= 51#comment-13408651 ]=20 Gilles commented on MATH-812: ----------------------------- bq. [...] robustness should probably be preferred over speed in default imp= lementations. +1 =20 > In RealVector, dotProduct and outerProduct return wrong results due to mi= suse of sparse iterators > -------------------------------------------------------------------------= ------------------------ > > Key: MATH-812 > URL: https://issues.apache.org/jira/browse/MATH-812 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.0 > Reporter: S=C3=A9bastien Brisard > Assignee: S=C3=A9bastien Brisard > Labels: linear, sparse > Fix For: 3.1 > > > In class {{RealVector}}, the default implementation of {{RealMatrix outer= Product(RealVector)}} uses sparse iterators on the entries of the two vecto= rs. The rationale behind this is that {{0d * x =3D=3D 0d}} is {{true}} for = all {{double x}}. This assumption is in fact false, since {{0d * NaN =3D=3D= NaN}}. > Proposed fix is to loop through *all* entries of both vectors. This can h= ave a significant impact on the CPU cost, but robustness should probably be= preferred over speed in default implementations. > Same issue occurs with {{double dotProduct(RealVector)}}, which uses spar= se iterators for {{this}} only. > Another option would be to through an exception if {{isNaN()}} is {{true}= }, in which case caching could be used for both {{isNaN()}} and {{isInfinit= e()}}. -- 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