[jira] [Created] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

ASF GitHub Bot (Jira)
Sébastien Brisard created MATH-812:
--------------------------------------

             Summary: In RealVector, dotProduct and outerProduct return wrong results due to misuse 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ébastien Brisard
            Assignee: Sébastien Brisard
             Fix For: 3.1


In class {{RealVector}}, the default implementation of {{RealMatrix outerProduct(RealVector)}} uses sparse iterators on the entries of the two vectors. The rationale behind this is that {{0d * x == 0d}} is {{true}} for all {{double x}}. This assumption is in fact false, since {{0d * NaN == NaN}}.

Proposed fix is to loop through *all* entries of both vectors. This can have 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 sparse 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 {{isInfinite()}}.

--
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


Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/MATH-812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13408651#comment-13408651 ]

Gilles commented on MATH-812:
-----------------------------

bq. [...] robustness should probably be preferred over speed in default implementations.

+1

               

> In RealVector, dotProduct and outerProduct return wrong results due to misuse 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ébastien Brisard
>            Assignee: Sébastien Brisard
>              Labels: linear, sparse
>             Fix For: 3.1
>
>
> In class {{RealVector}}, the default implementation of {{RealMatrix outerProduct(RealVector)}} uses sparse iterators on the entries of the two vectors. The rationale behind this is that {{0d * x == 0d}} is {{true}} for all {{double x}}. This assumption is in fact false, since {{0d * NaN == NaN}}.
> Proposed fix is to loop through *all* entries of both vectors. This can have 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 sparse 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 {{isInfinite()}}.

--
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


Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/MATH-812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13412767#comment-13412767 ]

Sébastien Brisard commented on MATH-812:
----------------------------------------

In {{r1360662}}, {{RealVector.dotProduct(RealVector)}} now loops through all entries of the vectors.
               

> In RealVector, dotProduct and outerProduct return wrong results due to misuse 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ébastien Brisard
>            Assignee: Sébastien Brisard
>              Labels: linear, sparse
>             Fix For: 3.1
>
>
> In class {{RealVector}}, the default implementation of {{RealMatrix outerProduct(RealVector)}} uses sparse iterators on the entries of the two vectors. The rationale behind this is that {{0d * x == 0d}} is {{true}} for all {{double x}}. This assumption is in fact false, since {{0d * NaN == NaN}}.
> Proposed fix is to loop through *all* entries of both vectors. This can have 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 sparse 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 {{isInfinite()}}.

--
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


Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/MATH-812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13412777#comment-13412777 ]

Sébastien Brisard commented on MATH-812:
----------------------------------------

In {{r1360668}}, {{RealVector.outerProduct(RealVector)}} now loops through all entries of the vectors.
               

> In RealVector, dotProduct and outerProduct return wrong results due to misuse 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ébastien Brisard
>            Assignee: Sébastien Brisard
>              Labels: linear, sparse
>             Fix For: 3.1
>
>
> In class {{RealVector}}, the default implementation of {{RealMatrix outerProduct(RealVector)}} uses sparse iterators on the entries of the two vectors. The rationale behind this is that {{0d * x == 0d}} is {{true}} for all {{double x}}. This assumption is in fact false, since {{0d * NaN == NaN}}.
> Proposed fix is to loop through *all* entries of both vectors. This can have 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 sparse 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 {{isInfinite()}}.

--
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


Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (MATH-812) In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Sébastien Brisard resolved MATH-812.
------------------------------------

    Resolution: Fixed

Unit tests now pass, at the price of a performance loss.
               

> In RealVector, dotProduct and outerProduct return wrong results due to misuse 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ébastien Brisard
>            Assignee: Sébastien Brisard
>              Labels: linear, sparse
>             Fix For: 3.1
>
>
> In class {{RealVector}}, the default implementation of {{RealMatrix outerProduct(RealVector)}} uses sparse iterators on the entries of the two vectors. The rationale behind this is that {{0d * x == 0d}} is {{true}} for all {{double x}}. This assumption is in fact false, since {{0d * NaN == NaN}}.
> Proposed fix is to loop through *all* entries of both vectors. This can have 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 sparse 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 {{isInfinite()}}.

--
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