diff options
| author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-06 17:06:06 +0000 |
|---|---|---|
| committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-11-06 17:06:06 +0000 |
| commit | 2f4b825ca130cdb04490571b58a80bbed52c6f0a (patch) | |
| tree | e80c46c7eb646da75d5e49de5a4b8482f7154915 /llvm/test/heapsort.c | |
| parent | 074d52d60d2576e92400a92ec4f48ebfff55a912 (diff) | |
| download | bcm5719-llvm-2f4b825ca130cdb04490571b58a80bbed52c6f0a.tar.gz bcm5719-llvm-2f4b825ca130cdb04490571b58a80bbed52c6f0a.zip | |
Moved *.c files into subdirectory TestSources to avoid overwriting
corresponding *.ll files.
llvm-svn: 1155
Diffstat (limited to 'llvm/test/heapsort.c')
| -rw-r--r-- | llvm/test/heapsort.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/llvm/test/heapsort.c b/llvm/test/heapsort.c deleted file mode 100644 index 17c1185ddcd..00000000000 --- a/llvm/test/heapsort.c +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- mode: c -*- - * $Id$ - * http://www.bagley.org/~doug/shootout/ - */ - -#include <stdlib.h> -#include <math.h> -#include <stdio.h> - -#define IM 139968 -#define IA 3877 -#define IC 29573 - -double -gen_random(double max) { - static long last = 42; - return( max * (last = (last * IA + IC) % IM) / IM ); -} - -void -heapsort(int n, double *ra) { - int i, j; - int ir = n; - int l = (n >> 1) + 1; - double rra; - - for (;;) { - if (l > 1) { - rra = ra[--l]; - } else { - rra = ra[ir]; - ra[ir] = ra[1]; - if (--ir == 1) { - ra[1] = rra; - return; - } - } - - i = l; - j = l << 1; - while (j <= ir) { - if (j < ir && ra[j] < ra[j+1]) { - ++j; - } - if (rra < ra[j]) { - ra[i] = ra[j]; - j += (i = j); - } else { - j = ir + 1; - } - } - ra[i] = rra; - } -} - -int -main(int argc, char *argv[]) { - int N = ((argc == 2) ? atoi(argv[1]) : 10); - double *ary; - int i; - - /* create an array of N random doubles */ - ary = (double *)malloc((N+1) * sizeof(double)); - for (i=1; i<=N; i++) { - ary[i] = gen_random(1); - } - - heapsort(N, ary); - - printf("%f\n", ary[N]); - - free(ary); - return(0); -} - |

