@Test public void sortObject() { int numBins = 150; double tolerance = 15.0/numBins; double[] data = random(-5,10,4,200); SortableParameter_F64[] objs = convert(data); ApproximateSort_F64 alg = new ApproximateSort_F64(-5,10,numBins); alg.sortObject(objs, 4, 200); // see if the sort was to within the expected tolerance for( int i = 5; i < objs.length; i++ ) { assertTrue( objs[i].sortValue > objs[i-1].sortValue -tolerance ); } }
@Test public void computeRange_object() { ApproximateSort_F64 alg = new ApproximateSort_F64(12); double[] data = random(-5,10,4,200); SortableParameter_F64[] objs = convert(data); double min = Double.MAX_VALUE; double max = -Double.MAX_VALUE; for( int i = 4; i < data.length; i++ ) { if( data[i] < min ) min = data[i]; if( data[i] > max ) max = data[i]; } alg.computeRange(objs,4,200); assertEquals(min,alg.minValue,1e-8); assertEquals(max,alg.maxValue,1e-8); }