I have a method to check for equality of 2 double[]'s with a tolerance between each element. I'd like to make this faster and am wondering if there is a way to do this without a for loop. I've been searching but can't find something that does this. The Arrays.equals() or deepEquals() doesn't seem to take a tolerance for double equality. Any suggestions? This is what I have currently:
private boolean myEquals(double[] array1, double[] array2)
{
if(array1.length == array2.length)
{
for(int i = 0; i < array1.length; i++)
{
if(Math.abs(array1[i] - array2[i]) > 0.01)
{
return false;
}
}
}
else
{
return false;
}
return true;
}