2006-02-26 15:00:58 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Based on public-domain code from Berkeley Yacc */
|
2004-08-16 10:50:37 +01:00
|
|
|
|
2006-02-26 15:00:58 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-05-18 13:06:29 +01:00
|
|
|
#include "mymalloc.h"
|
|
|
|
|
2006-02-26 15:00:58 +00:00
|
|
|
/* machine-dependent definitions */
|
|
|
|
/* the following definitions are for the Tahoe */
|
|
|
|
/* they might have to be changed for other machines */
|
|
|
|
|
|
|
|
/* MAXCHAR is the largest unsigned character value */
|
|
|
|
/* MAXSHORT is the largest value of a C short */
|
|
|
|
/* MINSHORT is the most negative value of a C short */
|
|
|
|
/* MAXTABLE is the maximum table size */
|
|
|
|
/* BITS_PER_WORD is the number of bits in a C unsigned */
|
|
|
|
/* WORDSIZE computes the number of words needed to */
|
|
|
|
/* store n bits */
|
|
|
|
/* BIT returns the value of the n-th bit starting */
|
|
|
|
/* from r (0-indexed) */
|
|
|
|
/* SETBIT sets the n-th bit starting from r */
|
|
|
|
|
|
|
|
#define MAXCHAR UCHAR_MAX
|
|
|
|
#define MAXSHORT SHRT_MAX
|
|
|
|
#define MINSHORT SHRT_MIN
|
|
|
|
#define MAXTABLE 32500
|
|
|
|
|
|
|
|
#define BITS_PER_WORD (8*sizeof(unsigned))
|
|
|
|
#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
|
|
|
|
#define BIT(r, n) ((((r)[(n)/BITS_PER_WORD])>>((n)%BITS_PER_WORD))&1)
|
|
|
|
#define SETBIT(r, n) ((r)[(n)/BITS_PER_WORD]|=(1<<((n)%BITS_PER_WORD)))
|
|
|
|
|
|
|
|
/* storage allocation macros */
|
|
|
|
|
|
|
|
#define CALLOC(k,n) (calloc((unsigned)(k),(unsigned)(n)))
|
|
|
|
#define FREE(x) (free((char*)(x)))
|
|
|
|
#define MALLOC(n) (malloc((unsigned)(n)))
|
2007-01-27 10:33:15 +00:00
|
|
|
//#define REALLOC(p,n) (realloc((char*)(p),(unsigned)(n)))
|
2006-02-26 15:00:58 +00:00
|
|
|
|
|
|
|
/* actual functions */
|
|
|
|
|
|
|
|
void transitive_closure (unsigned int *R, int n);
|
|
|
|
void reflexive_transitive_closure (unsigned int *R, int n);
|