static public void compareData(Array data1, Array data2) {
assert data1.getSize() == data2.getSize();
assert data1.getElementType() == data2.getElementType() : data1.getElementType()+"!="+ data2.getElementType();
DataType dt = DataType.getType( data1.getElementType());
IndexIterator iter1 = data1.getIndexIterator();
IndexIterator iter2 = data2.getIndexIterator();
if (dt == DataType.DOUBLE) {
while (iter1.hasNext()) {
double v1 = iter1.getDoubleNext();
double v2 = iter2.getDoubleNext();
if (!Double.isNaN(v1) || !Double.isNaN(v2))
assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
}
}
else if (dt == DataType.FLOAT) {
while (iter1.hasNext()) {
float v1 = iter1.getFloatNext();
float v2 = iter2.getFloatNext();
if (!Float.isNaN(v1) || !Float.isNaN(v2))
assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
}
}
else if (dt == DataType.INT) {
while (iter1.hasNext()) {
int v1 = iter1.getIntNext();
int v2 = iter2.getIntNext();
assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
}
}
else if (dt == DataType.SHORT) {
while (iter1.hasNext()) {
short v1 = iter1.getShortNext();
short v2 = iter2.getShortNext();
assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
}
}
else if (dt == DataType.BYTE) {
while (iter1.hasNext()) {
byte v1 = iter1.getByteNext();
byte v2 = iter2.getByteNext();
assert v1 == v2 : v1 + " != "+ v2+" count="+iter1;
}
}
}