File: ADJ_2D1.c

package info (click to toggle)
qepcad 1.74%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,848 kB
  • sloc: ansic: 27,242; cpp: 2,995; makefile: 1,287; perl: 91
file content (124 lines) | stat: -rw-r--r-- 2,777 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*======================================================================
                      L <- ADJ_2D1(c,c_l,P,J)

Adjacency for 2D CAD cells.

Inputs
  c  : a section cell in the 1D CAD.
  c_l: a neighbor of c.
  P  : the projection factor set.
  J  : the projection polynomial set.

Outputs
  L  : a list of elements of the form ((i,j),(k,l))
       indicating an adjacency between cell (i,j) and cell (k,l).
======================================================================*/
#include "adj2D.h"
#include "adj2D.h"
/**************************************/
/*
static FILE *OUTPUT;

static void init()
{
  OUTPUT = fopen("stats_ADJ_2D1","a");
}
void sa_send(const char* S)
{
  fprintf(OUTPUT,"%s",S);
}
static void uninit()
{
  fclose(OUTPUT);
}
*/
/**************************************/






#define tImIngs

#ifdef  tImIngs
Word ADJ_2D1(Word c, Word c_l, Word P, Word J)
{
  Word U,V,v_l,Sol,S,A,Ap,a,b;
  /*
init();
sa_send("[");
  */
Step1: /* Initialization. */
  v_l = LDCOEFMASK(c,P,J);
  U = AD2DS_CONS(c_l,P);
  V = AD2DS_CONS(c,P);

Step2: /* Get Adjacencies. */
  /* Sol = ADJ_2D1_SIMPLE(U,V,v_l,FIRST(LELTI(c,INDX))); */
  Sol = ADJ_2D1P1(U,V,v_l,FIRST(LELTI(c,INDX)));

Step3: /* If c_l is to the right of c, reverse order of pairs. */
  if (FIRST(LELTI(c,INDX)) < FIRST(LELTI(c_l,INDX))) {
    for(S = NIL; Sol != NIL; Sol = RED(Sol)) {
      for(A = NIL, Ap = FIRST(Sol); Ap != NIL; Ap = RED(Ap)) {
	FIRST2(FIRST(Ap),&a,&b);
	A = COMP(LIST2(b,a),A); }
      S = COMP(A,S); }
    Sol = S; }

Return: /* Prepare to return. */
  /*
  sa_send("]\n");
  uninit();
  */
  return Sol;
}

#else

Word ADJ_2D1(Word c, Word c_l, Word P, Word J)
{
  Word U,V,v_l,Sol,S,A,Ap,a,b;
  Word t,i,I = 1000;

Step1: /* Initialization. */
  printf("\n");
  t = ACLOCK();
  for(i = 0; i < I; i++)
    v_l = LDCOEFMASK(c,P,J);
  t = ACLOCK() - t;
  printf("LDCOEFMASK:        %6.3f\n",t/(float)I);
  t = ACLOCK();
  for(i = 0; i < I; i++)    
    U = AD2DS_CONS(c_l,P);
  t = ACLOCK()-t;
  printf("AD2DS_CONS open:   %6.3f\n",t/(float)I);
  t = ACLOCK();
  for(i = 0; i < I; i++)    
    V = AD2DS_CONS(c,P);
  t = ACLOCK()-t;
  printf("AD2DS_CONS closed: %6.3f\n",t/(float)I);

Step2: /* Get Adjacencies. */
  t = ACLOCK();
  for(i = 0; i < I; i++)    
    Sol = ADJ_2D1P1(U,V,v_l,FIRST(LELTI(c,INDX)));
  t = ACLOCK()-t;
  printf("ADJ_2D1P1:         %6.3f\n",t/(float)I);
  printf("\n");

Step3: /* If c_l is to the right of c, reverse order of pairs. */
  if (FIRST(LELTI(c,INDX)) < FIRST(LELTI(c_l,INDX))) {
    for(S = NIL; Sol != NIL; Sol = RED(Sol)) {
      for(A = NIL, Ap = FIRST(Sol); Ap != NIL; Ap = RED(Ap)) {
	FIRST2(FIRST(Ap),&a,&b);
	A = COMP(LIST2(b,a),A); }
      S = COMP(A,S); }
    Sol = S; }

Return: /* Prepare to return. */
  return Sol;
}

#endif