Some adjustments to the recent dsched removal.
[dragonfly.git] / contrib / byacc / warshall.c
blobefb7cf447974d04d007d90d629463c2e9425e9e2
1 /* $Id: warshall.c,v 1.7 2010/06/06 22:48:51 tom Exp $ */
3 #include "defs.h"
5 static void
6 transitive_closure(unsigned *R, int n)
8 int rowsize;
9 unsigned i;
10 unsigned *rowj;
11 unsigned *rp;
12 unsigned *rend;
13 unsigned *ccol;
14 unsigned *relend;
15 unsigned *cword;
16 unsigned *rowi;
18 rowsize = WORDSIZE(n);
19 relend = R + n * rowsize;
21 cword = R;
22 i = 0;
23 rowi = R;
24 while (rowi < relend)
26 ccol = cword;
27 rowj = R;
29 while (rowj < relend)
31 if (*ccol & (unsigned)(1 << i))
33 rp = rowi;
34 rend = rowj + rowsize;
35 while (rowj < rend)
36 *rowj++ |= *rp++;
38 else
40 rowj += rowsize;
43 ccol += rowsize;
46 if (++i >= BITS_PER_WORD)
48 i = 0;
49 cword++;
52 rowi += rowsize;
56 void
57 reflexive_transitive_closure(unsigned *R, int n)
59 int rowsize;
60 unsigned i;
61 unsigned *rp;
62 unsigned *relend;
64 transitive_closure(R, n);
66 rowsize = WORDSIZE(n);
67 relend = R + n * rowsize;
69 i = 0;
70 rp = R;
71 while (rp < relend)
73 *rp |= (unsigned)(1 << i);
74 if (++i >= BITS_PER_WORD)
76 i = 0;
77 rp++;
80 rp += rowsize;