Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-812

In RealVector, dotProduct and outerProduct return wrong results due to misuse of sparse iterators

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.1
    • None

    Description

      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().

      Attachments

        Activity

          People

            celestin Sebastien Brisard
            celestin Sebastien Brisard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: