DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T b

⟦1eff732d2⟧ TextFile

    Length: 1075 (0x433)
    Types: TextFile
    Names: »bytesort.c«

Derivation

└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/utah/bytesort.c« 
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21F/utah/bytesort.c« 

TextFile

#define	REG	register
#define MAXNUM	1000
#define	COUNT	10
#define	MODULUS	((long) 0x20000)

#define	C	13849L
#define	A	25173L

long	seed = 7L;

long	random();

long	buffer[MAXNUM] = {0};

main()
{
	REG int		i, j;
	long	temp;

	printf("Filling array and sorting %d times\n", COUNT);
	for (i = 0; i < COUNT; ++i)
	{
		for (j = 0; j < MAXNUM; ++j)
		{
			temp = random(MODULUS);
			if (temp < 0L)
				temp = -temp;
			buffer[j] = temp;
		}
		printf("Buffer full, iteration %d\n", i);
		quick(0, MAXNUM, buffer);
	}
	printf("Done\n");
	exit(0);
}

quick(lo, hi, base)
int	lo, hi;
long	base[];
{
	REG int		i, j;
	long		pivot, temp;

	if (lo < hi)
	{
		for (i = lo, j = hi, pivot = base[hi]; i < j; )
		{
			while (i < j && base[i] < pivot)
				++i;
			while (j > i && base[j] > pivot)
				--j;
			if (i < j)
			{
				temp = base[i];
				base[i] = base[j];
				base[j] = temp;
			}
		}
		temp = base[i];
		base[i] = base[hi];
		base[hi] = temp;
		quick(lo, i - 1, base);
		quick(i + 1, hi, base);
	}
}

long random(size)
long	size;
{
	seed = seed * A + C;
	return (seed % size);
}