diff --git a/core/src/main/java/net/librec/math/structure/VectorBasedSequentialSparseVector.java b/core/src/main/java/net/librec/math/structure/VectorBasedSequentialSparseVector.java index e109a4a5c..591e84367 100644 --- a/core/src/main/java/net/librec/math/structure/VectorBasedSequentialSparseVector.java +++ b/core/src/main/java/net/librec/math/structure/VectorBasedSequentialSparseVector.java @@ -62,7 +62,7 @@ public VectorBasedSequentialSparseVector(Vector other) { List nonZeros = new ArrayList(); for (VectorEntry e : other) { double value = e.get(); - if (value != 0d && value != Double.NaN) { + if (value != 0d && !Double.isNaN(value)) { nonZeros.add(value); } } @@ -93,7 +93,7 @@ private OrderedIntDoubleMapping copySortedRandomAccessSparseVector(Vector other) // get nonZero values for (VectorEntry vectorEntry : other) { double value = vectorEntry.get(); - if (value != 0d && value != Double.NaN) { + if (value != 0d && !Double.isNaN(value)) { sortableEntries[elementIndex++] = new OrderedVectorElement(vectorEntry.index(), value); } }