/** * Sorts indices of the elements of the specified array in ascending order. * After sorting, a[i[0]] <= a[i[1]] <= a[i[2]] <= .... * @param a the array. * @param i the indices to be sorted. */ public static void quickIndexSort(short[] a, int[] i) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,i,0,n-1); } else { int[] m = new int[2]; quickSort(a,i,0,n-1,m); } }
/** * Sorts the elements of the specified array in ascending order. * After sorting, a[0] <= a[1] <= a[2] <= .... * @param a the array to be sorted. */ public static void quickSort(double[] a) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,0,n-1); } else { int[] m = new int[2]; quickSort(a,0,n-1,m); } }
/** * Sorts indices of the elements of the specified array in ascending order. * After sorting, a[i[0]] <= a[i[1]] <= a[i[2]] <= .... * @param a the array. * @param i the indices to be sorted. */ public static void quickIndexSort(double[] a, int[] i) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,i,0,n-1); } else { int[] m = new int[2]; quickSort(a,i,0,n-1,m); } }
/** * Sorts the elements of the specified array in ascending order. * After sorting, a[0] <= a[1] <= a[2] <= .... * @param a the array to be sorted. */ public static void quickSort(float[] a) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,0,n-1); } else { int[] m = new int[2]; quickSort(a,0,n-1,m); } }
/** * Sorts the elements of the specified array in ascending order. * After sorting, a[0] <= a[1] <= a[2] <= .... * @param a the array to be sorted. */ public static void quickSort(byte[] a) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,0,n-1); } else { int[] m = new int[2]; quickSort(a,0,n-1,m); } }
/** * Sorts the elements of the specified array in ascending order. * After sorting, a[0] <= a[1] <= a[2] <= .... * @param a the array to be sorted. */ public static void quickSort(short[] a) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,0,n-1); } else { int[] m = new int[2]; quickSort(a,0,n-1,m); } }
/** * Sorts the elements of the specified array in ascending order. * After sorting, a[0] <= a[1] <= a[2] <= .... * @param a the array to be sorted. */ public static void quickSort(int[] a) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,0,n-1); } else { int[] m = new int[2]; quickSort(a,0,n-1,m); } }
/** * Sorts the elements of the specified array in ascending order. * After sorting, a[0] <= a[1] <= a[2] <= .... * @param a the array to be sorted. */ public static void quickSort(long[] a) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,0,n-1); } else { int[] m = new int[2]; quickSort(a,0,n-1,m); } }
private static void quickSort(byte[] a, int p, int q, int[] m) { if (q-p<=NSMALL_SORT) { insertionSort(a,p,q); } else { m[0] = p; m[1] = q; quickPartition(a,m); int r = m[0]; int s = m[1]; if (p<r-1) quickSort(a,p,r-1,m); if (q>s+1) quickSort(a,s+1,q,m); } } private static void quickSort(byte[] a, int[] i, int p, int q, int[] m) {
/** * Sorts indices of the elements of the specified array in ascending order. * After sorting, a[i[0]] <= a[i[1]] <= a[i[2]] <= .... * @param a the array. * @param i the indices to be sorted. */ public static void quickIndexSort(float[] a, int[] i) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,i,0,n-1); } else { int[] m = new int[2]; quickSort(a,i,0,n-1,m); } }
private static void quickSort(byte[] a, int[] i, int p, int q, int[] m) { if (q-p<=NSMALL_SORT) { insertionSort(a,i,p,q); } else { m[0] = p; m[1] = q; quickPartition(a,i,m); int r = m[0]; int s = m[1]; if (p<r-1) quickSort(a,i,p,r-1,m); if (q>s+1) quickSort(a,i,s+1,q,m); } } private static void quickPartition(byte[] x, int[] m) {
private static void quickSort(short[] a, int p, int q, int[] m) { if (q-p<=NSMALL_SORT) { insertionSort(a,p,q); } else { m[0] = p; m[1] = q; quickPartition(a,m); int r = m[0]; int s = m[1]; if (p<r-1) quickSort(a,p,r-1,m); if (q>s+1) quickSort(a,s+1,q,m); } } private static void quickSort(short[] a, int[] i, int p, int q, int[] m) {
private static void quickSort(long[] a, int[] i, int p, int q, int[] m) { if (q-p<=NSMALL_SORT) { insertionSort(a,i,p,q); } else { m[0] = p; m[1] = q; quickPartition(a,i,m); int r = m[0]; int s = m[1]; if (p<r-1) quickSort(a,i,p,r-1,m); if (q>s+1) quickSort(a,i,s+1,q,m); } } private static void quickPartition(long[] x, int[] m) {
private static void quickSort(float[] a, int p, int q, int[] m) { if (q-p<=NSMALL_SORT) { insertionSort(a,p,q); } else { m[0] = p; m[1] = q; quickPartition(a,m); int r = m[0]; int s = m[1]; if (p<r-1) quickSort(a,p,r-1,m); if (q>s+1) quickSort(a,s+1,q,m); } } private static void quickSort(float[] a, int[] i, int p, int q, int[] m) {
private static void quickSort(double[] a, int[] i, int p, int q, int[] m) { if (q-p<=NSMALL_SORT) { insertionSort(a,i,p,q); } else { m[0] = p; m[1] = q; quickPartition(a,i,m); int r = m[0]; int s = m[1]; if (p<r-1) quickSort(a,i,p,r-1,m); if (q>s+1) quickSort(a,i,s+1,q,m); } } private static void quickPartition(double[] x, int[] m) {
/** * Sorts indices of the elements of the specified array in ascending order. * After sorting, a[i[0]] <= a[i[1]] <= a[i[2]] <= .... * @param a the array. * @param i the indices to be sorted. */ public static void quickIndexSort(byte[] a, int[] i) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,i,0,n-1); } else { int[] m = new int[2]; quickSort(a,i,0,n-1,m); } }
/** * Sorts indices of the elements of the specified array in ascending order. * After sorting, a[i[0]] <= a[i[1]] <= a[i[2]] <= .... * @param a the array. * @param i the indices to be sorted. */ public static void quickIndexSort(long[] a, int[] i) { int n = a.length; if (n<NSMALL_SORT) { insertionSort(a,i,0,n-1); } else { int[] m = new int[2]; quickSort(a,i,0,n-1,m); } }
private static float[][][] sampleTestFunction(int n1, int n2) { Random r = new Random(3); float[] x1 = mul(2.0f,randfloat(r,n1)); float[] x2 = mul(2.0f,randfloat(r,n2)); quickSort(x1); quickSort(x2); float[][] y = new float[n2][n1]; for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = testFunction00(x1[i1],x2[i2]); return new float[][][]{new float[][]{x1,x2},y}; } private static float testFunction00(float x1, float x2) {
private static float[][][] sampleTestFunction(int n1, int n2) { Random r = new Random(3); float[] x1 = mul(2.0f,randfloat(r,n1)); float[] x2 = mul(2.0f,randfloat(r,n2)); quickSort(x1); quickSort(x2); float[][] y = new float[n2][n1]; for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i2][i1] = testFunction00(x1[i1],x2[i2]); return new float[][][]{new float[][]{x1,x2},y}; } private static float testFunction00(float x1, float x2) {
private static float[][][][] sampleTestFunction(int n1, int n2, int n3) { Random r = new Random(3); float[] x1 = mul(2.0f,randfloat(r,n1)); float[] x2 = mul(2.0f,randfloat(r,n2)); float[] x3 = mul(2.0f,randfloat(r,n3)); quickSort(x1); quickSort(x2); quickSort(x3); float[][][] y = new float[n3][n2][n1]; for (int i3=0; i3<n3; ++i3) for (int i2=0; i2<n2; ++i2) for (int i1=0; i1<n1; ++i1) y[i3][i2][i1] = testFunction000(x1[i1],x2[i2],x3[i3]); return new float[][][][]{new float[][][]{{x1,x2,x3}},y}; } private static float testFunction000(float x1, float x2, float x3) {