@Test public void test_F32() { float[] ret = BenchMarkSort.createRandom_F32(rand,200); ShellSort.sort(ret); float prev = ret[0]; for( int i = 1; i < ret.length; i++ ) { if( ret[i] < prev ) fail("Not ascending"); prev = ret[i]; } }
@Test public void test_F64() { double[] ret = BenchMarkSort.createRandom_F64(rand,200); ShellSort.sort(ret); double prev = ret[0]; for( int i = 1; i < ret.length; i++ ) { if( ret[i] < prev ) fail("Not ascending"); prev = ret[i]; } }
@Test public void test_S32() { int[] ret = BenchMarkSort.createRandom_S32(rand,200); ShellSort.sort(ret); double prev = ret[0]; for( int i = 1; i < ret.length; i++ ) { if( ret[i] < prev ) fail("Not ascending"); prev = ret[i]; } }
@Test public void testSortDouble() { double[] ret = BenchMarkSort.createRandom_F64(rand,200); StraightInsertionSort.sort(ret); double prev = ret[0]; for( int i = 1; i < ret.length; i++ ) { if( ret[i] < prev ) fail("Not ascending"); } } }
@Test public void testSortingRandom_indexes_S32() { int offset = 10; for( int a = 0; a < 20; a++ ) { int[] normal = BenchMarkSort.createRandom_S32(rand,20); int[] original = normal.clone(); int[] withIndexes = new int[offset+normal.length];; int[] indexes = new int[ withIndexes.length ]; System.arraycopy(normal,0,withIndexes,offset,normal.length); ShellSort.sort(normal); ShellSort.sort(withIndexes,offset,normal.length,indexes); for( int i = 0; i < normal.length; i++ ) { // make sure the original hasn't been modified assertEquals(original[i],withIndexes[i+offset], UtilEjml.TEST_F64); // see if it produced the same results as the normal one assertEquals(normal[i],withIndexes[indexes[i]],UtilEjml.TEST_F64); } } } }
@Test public void testSortingRandom_indexes_F32() { int offset = 10; for( int a = 0; a < 20; a++ ) { float[] normal = BenchMarkSort.createRandom_F32(rand,20); float[] original = normal.clone(); float[] withIndexes = new float[offset+normal.length];; int[] indexes = new int[ withIndexes.length ]; System.arraycopy(normal,0,withIndexes,offset,normal.length); ShellSort.sort(normal); ShellSort.sort(withIndexes,offset,normal.length,indexes); for( int i = 0; i < normal.length; i++ ) { // make sure the original hasn't been modified assertEquals(original[i],withIndexes[i+offset], UtilEjml.TEST_F32); // see if it produced the same results as the normal one assertEquals(normal[i],withIndexes[indexes[i]],UtilEjml.TEST_F32); } } }
@Test public void testSortingRandom_indexes_F64() { int offset = 10; for( int a = 0; a < 20; a++ ) { double[] normal = BenchMarkSort.createRandom_F64(rand,20); double[] original = normal.clone(); double[] withIndexes = new double[offset+normal.length];; int[] indexes = new int[ withIndexes.length ]; System.arraycopy(normal,0,withIndexes,offset,normal.length); ShellSort.sort(normal); ShellSort.sort(withIndexes,offset,normal.length,indexes); for( int i = 0; i < normal.length; i++ ) { // make sure the original hasn't been modified assertEquals(original[i],withIndexes[i+offset], UtilEjml.TEST_F64); // see if it produced the same results as the normal one assertEquals(normal[i],withIndexes[indexes[i]],UtilEjml.TEST_F64); } } }
@Test public void testSortingRandom_indexes() { int offset = 10; for( int a = 0; a < 20; a++ ) { int[] normal = BenchMarkSort.createRandom_S32(rand,20); int[] original = normal.clone(); int[] withIndexes = new int[offset+normal.length];; int[] indexes = new int[ withIndexes.length ]; System.arraycopy(normal,0,withIndexes,offset,normal.length); QuickSort_S32 sorter = new QuickSort_S32(); sorter.sort(normal,normal.length); sorter.sort(withIndexes,offset,normal.length,indexes); for( int i = 0; i < normal.length; i++ ) { // make sure the original hasn't been modified assertEquals(original[i],withIndexes[i+offset], UtilEjml.TEST_F64); // see if it produced the same results as the normal one assertEquals(normal[i],withIndexes[indexes[i]],UtilEjml.TEST_F64); } } } }
@Test public void testSortingRandom_indexes() { int offset = 10; for( int a = 0; a < 20; a++ ) { double[] normal = BenchMarkSort.createRandom_F64(rand,20); double[] original = normal.clone(); double[] withIndexes = new double[offset+normal.length];; int[] indexes = new int[ withIndexes.length ]; System.arraycopy(normal,0,withIndexes,offset,normal.length); QuickSort_F64 sorter = new QuickSort_F64(); sorter.sort(normal,normal.length); sorter.sort(withIndexes,offset,normal.length,indexes); for( int i = 0; i < normal.length; i++ ) { // make sure the original hasn't been modified assertEquals(original[i],withIndexes[i+offset], UtilEjml.TEST_F64); // see if it produced the same results as the normal one assertEquals(normal[i],withIndexes[indexes[i]],UtilEjml.TEST_F64); } } } }
@Test public void testSortingRandom() { int[] ret = BenchMarkSort.createRandom_S32(rand,200); int preTotal = sum(ret); QuickSort_S32 sorter = new QuickSort_S32(); sorter.sort(ret,ret.length); int postTotal = sum(ret); // make sure it didn't modify the list, in an unexpected way assertEquals(preTotal,postTotal,1e-8); double prev = ret[0]; for( int i = 1; i < ret.length; i++ ) { if( ret[i] < prev ) fail("Not ascending"); prev = ret[i]; } }
@Test public void testSortingRandom() { double[] ret = BenchMarkSort.createRandom_F64(rand,200); double preTotal = UtilDouble.sum(ret); QuickSort_F64 sorter = new QuickSort_F64(); sorter.sort(ret,ret.length); double postTotal = UtilDouble.sum(ret); // make sure it didn't modify the list, in an unexpected way assertEquals(preTotal,postTotal,UtilEjml.TEST_F64); double prev = ret[0]; for( int i = 1; i < ret.length; i++ ) { if( ret[i] < prev ) fail("Not ascending"); prev = ret[i]; } }