simpleqt opened a new pull request, #361:
URL: https://github.com/apache/commons-math/pull/361

   `OpenMapRealVector.getLInfDistance(OpenMapRealVector)` takes `abs(this[i] - 
v[i])` for the keys stored in `this`, but for keys stored only in `v` it 
compares the raw `v[i]` — although `this[i]` is the default 0 there. A negative 
value can never raise the maximum, so two vectors that differ only by a 
negative entry of `v` report an L-inf distance of 0:
   
   ```java
   new OpenMapRealVector(new double[] {0d, 0d})
       .getLInfDistance(new OpenMapRealVector(new double[] {0d, -5d})) // 0.0, 
expected 5.0
   ```
   
   The same input against an `ArrayRealVector` returns 5.0 (the generic 
`RealVector#getLInfDistance(RealVector)` path), so the sparse overload also 
disagrees with the generic one depending on the argument type. `getDistance` 
squares the v-only entries and `getL1Distance` takes their absolute value; only 
the L-inf variant misses it.
   
   Fix: take the absolute value of the entries found only in `v` before 
comparing. Regression test added to `RealVectorAbstractTest` (runs for the 
Array / generic / sparse fixtures; fails on the unfixed sparse implementation 
with `expected:<5.0> but was:<0.0>`).
   
   Local checks: `mvn -pl commons-math-legacy test` — 3268 tests, 0 failures 
(30 skipped, 3 flaky rerun-passes in SimplexOptimizer [POWELL], pre-existing); 
`checkstyle:check` — 0 violations. SpotBugs/pmd not run locally.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to