Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,9 @@ private double getLInfDistance(OpenMapRealVector v)
while (iter.hasNext()) {
iter.advance();
int key = iter.key();
if (!entries.containsKey(key) && iter.value() > max) {
max = iter.value();
final double value = JdkMath.abs(iter.value());
if (!entries.containsKey(key) && value > max) {
max = value;
}
}
return max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,17 @@ public void testGetLInfDistanceMixedTypes() {
doTestGetLInfDistance(true);
}

@Test
public void testGetLInfDistanceWithNegativeEntries() {
final double x = getPreferredEntryValue();
final double[] data1 = new double[] { x, x };
final double[] data2 = new double[] { x, -5d };
final RealVector v1 = create(data1);
final RealVector v2 = create(data2);
Assert.assertEquals("", 5d, v1.getLInfDistance(v2), 0d);
Assert.assertEquals("", 5d, v1.getLInfDistance(createAlien(data2)), 0d);
}

@Test(expected = DimensionMismatchException.class)
public void testGetLInfDistanceDimensionMismatch() {
create(new double[4]).getLInfDistance(createAlien(new double[5]));
Expand Down