MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / equals

Method equals

JSAT/src/jsat/linear/SparseVector.java:810–841  ·  view source on GitHub ↗
(Object obj, double range)

Source from the content-addressed store, hash-verified

808 }
809
810 @Override
811 public boolean equals(Object obj, double range)
812 {
813 if(!(obj instanceof Vec))
814 return false;
815 Vec otherVec = (Vec) obj;
816 range = Math.abs(range);
817
818 if(this.length() != otherVec.length())
819 return false;
820
821
822 int z = 0;
823 for (int i = 0; i < length(); i++)
824 {
825 //Move through until we hit the next null element, comparing the other vec to zero
826 while (z < used && indexes[z] > i)
827 if (Math.abs(otherVec.get(i++)) > range)//We are zero!
828 return false;
829
830 //We made it! (or are at the end). Is our non zero value the same?
831 if (z < used && indexes[z] == i)
832 if (Math.abs(values[z++] - otherVec.get(i)) > range)
833 if (Double.isNaN(values[z++]) && Double.isNaN(otherVec.get(i)))//NaN != NaN is always true, so check special
834 return true;
835 else
836 return false;
837 }
838
839
840 return true;
841 }
842
843 @Override
844 public double[] arrayCopy()

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.95
lengthMethod · 0.95
getMethod · 0.95

Tested by

no test coverage detected