This is Unofficial EPICS BASE Doxygen Site
warshall.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 #include "defs.h"
10 
11 static void
12 transitive_closure(unsigned int *R, int n)
13 {
14  int rowsize;
15  unsigned i;
16  unsigned *rowj;
17  unsigned *rp;
18  unsigned *rend;
19  unsigned *ccol;
20  unsigned *relend;
21  unsigned *cword;
22  unsigned *rowi;
23 
24  rowsize = WORDSIZE(n);
25  relend = R + n*rowsize;
26 
27  cword = R;
28  i = 0;
29  rowi = R;
30  while (rowi < relend)
31  {
32  ccol = cword;
33  rowj = R;
34 
35  while (rowj < relend)
36  {
37  if (*ccol & (1 << i))
38  {
39  rp = rowi;
40  rend = rowj + rowsize;
41  while (rowj < rend)
42  *rowj++ |= *rp++;
43  }
44  else
45  {
46  rowj += rowsize;
47  }
48 
49  ccol += rowsize;
50  }
51 
52  if (++i >= BITS_PER_WORD)
53  {
54  i = 0;
55  cword++;
56  }
57 
58  rowi += rowsize;
59  }
60 }
61 
62 void
63 reflexive_transitive_closure(unsigned int *R, int n)
64 {
65  int rowsize;
66  unsigned i;
67  unsigned *rp;
68  unsigned *relend;
69 
70  transitive_closure(R, n);
71 
72  rowsize = WORDSIZE(n);
73  relend = R + n*rowsize;
74 
75  i = 0;
76  rp = R;
77  while (rp < relend)
78  {
79  *rp |= (1 << i);
80  if (++i >= BITS_PER_WORD)
81  {
82  i = 0;
83  rp++;
84  }
85 
86  rp += rowsize;
87  }
88 }
int i
Definition: scan.c:967
void reflexive_transitive_closure(unsigned int *R, int n)
Definition: warshall.c:63
#define BITS_PER_WORD
Definition: defs.h:33
#define WORDSIZE(n)
Definition: defs.h:34