commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Maisonobe (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (MATH-803) Bugs in RealVector.ebeMultiply(RealVector) and ebeDivide(RealVector)
Date Thu, 20 Feb 2014 15:59:20 GMT

     [ https://issues.apache.org/jira/browse/MATH-803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Luc Maisonobe resolved MATH-803.
--------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 4.0)
                   3.3

Methods undeprecated in r1570246.
The test cases have been adapted, and the fact we force 0 * x = 0 even for NaNs and infinities
is considered acceptable now, as it is similar to standard practive for sparse linear algebra
libraries.

> Bugs in RealVector.ebeMultiply(RealVector) and ebeDivide(RealVector)
> --------------------------------------------------------------------
>
>                 Key: MATH-803
>                 URL: https://issues.apache.org/jira/browse/MATH-803
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: S├ębastien Brisard
>             Fix For: 3.3
>
>
> {{OpenMapRealVector.ebeMultiply(RealVector)}} and {{OpenMapRealVector.ebeDivide(RealVector)}}
return wrong values when one entry of the specified {{RealVector}} is nan or infinity. The
bug is easy to understand. Here is the current implementation of {{ebeMultiply}}
> {code:java}
>     public OpenMapRealVector ebeMultiply(RealVector v) {
>         checkVectorDimensions(v.getDimension());
>         OpenMapRealVector res = new OpenMapRealVector(this);
>         Iterator iter = entries.iterator();
>         while (iter.hasNext()) {
>             iter.advance();
>             res.setEntry(iter.key(), iter.value() * v.getEntry(iter.key()));
>         }
>         return res;
>     }
> {code}
> The assumption is that for any double {{x}}, {{x * 0d == 0d}} holds, which is not true.
The bug is easy enough to identify, but more complex to solve. The only solution I can come
up with is to loop through *all* entries of v (instead of those entries which correspond to
non-zero entries of this). I'm afraid about performance losses.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message