-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdkset.c
More file actions
93 lines (70 loc) · 1.2 KB
/
dkset.c
File metadata and controls
93 lines (70 loc) · 1.2 KB
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
/*** DKSET.C ******/
void DKCe0()
{
for(int i=0;i<DCX;i++)C[i]=0;
iC=0;C[iC++]=0;C[iC++]=1;
wC=1;
}
void DKCprint(void)
{
printf("C: %d %d \n",iC,wC);
for(int i=0;i<iC;i++)DKbin(C[i]);
newl();
}
void DKCx2(void)
{
PNUM k;
LNUM a,b;
k=iC;
for(int i=1;i<k;i++)
for(int j=0;j<k;j++)
{
assert(iC<DCX);
a=C[i];b=C[j];
if(Dleq(a,b))C[iC++]=(a<<wC)+b;
}
wC*=2;
}
void DKexpanC(int pn)
{
LNUM tmp,rnm,pwm,mit;
PNUM lowC,kC;
int n;
n=pn;
assert(n>2);
DKgen(n);
printf("Loaded %d rules. \n",n);
C[0]=0;C[1]=1;C[2]=3;C[3]=5;C[4]=7;
lowC=5;kC=lowC;wC=3;
for(int m=wC;m<n;m++)
{
wC++;pwm=PW2[m];rnm=RN[m];
for(int i=1;i<lowC;i++)
{
tmp=C[i];tmp=tmp|pwm;
mit=tmp&rnm;
if(mit NE rnm)continue;
assert(kC LT DCX);
C[kC++]=tmp;
}
lowC=kC;
}
iC=lowC;
printf("Expan. C(%d)=[%d*%d] \n",n,wC,iC);
}
void DKCdemo(void)
{
int e,n;
printf("DKCdemo DKset.c \n");
printf("Duplicar C=(C*C); \n");
e=0;n=1;DKCe0();
while(e LT 5)
{
printf("C(%d,%d) ",e,n);
DKCx2();e++;n*=2;
printf(
" C(%d) [%d*%d] \n",n,wC,iC);
}
printf("Expandir desde cero.\n");
for(int n=14;n<17;n++)DKexpanC(n);
}