-
Notifications
You must be signed in to change notification settings - Fork 0
/
2quant.c
110 lines (108 loc) · 3.25 KB
/
2quant.c
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
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
clock_t t;
int m,n,k,i,j,l;
printf("Enter m\n");
scanf("%d",&m);
printf("Enter n\n");
scanf("%d",&n);
printf("Enter k\n");
scanf("%d",&k);
printf("Success");
int *a,*b,*c;
a = (int *)malloc(m*k*sizeof(int));
b = (int *)malloc(n*k*sizeof(int));
c = (int *)malloc(m*n*sizeof(int));
/*for(i=0;i<m;i++){
for(j=0;j<k;j++){
a[i][j]=0b00000000000000000000000000000000;
a[i][j]=a[i][j]|(0b00000000000000000000000000000011&)
}
}
for(i=0;i<k;i++){
for(j=0;j<n;j++){
b[i][j]
}
}*/
t = clock();
for(i=0;i<m;i++){
for(j=0;j<n;j++){
for(l=0;l<k;l++){
int p=0,q=0,r=0;
//unpacking
p = *(a+i*k+l)&0b00000000000000000000000000000011;
q = *(b+l*n+j)&0b00000000000000000000000000000011;
r = r|(p&q);
//2
p = *(a+i*k+l)&0b00000000000000000000000000001100;
q = *(b+l*n+j)&0b00000000000000000000000000001100;
r = r|(p&q);
//3
p = *(a+i*k+l)&0b00000000000000000000000000110000;
q = *(b+l*n+j)&0b00000000000000000000000000110000;
r = r|(p&q);
//4
p = *(a+i*k+l)&0b00000000000000000000000011000000;
q = *(b+l*n+j)&0b00000000000000000000000011000000;
r = r|(p&q);
//5
p = *(a+i*k+l)&0b00000000000000000000001100000000;
q = *(b+l*n+j)&0b00000000000000000000001100000000;
r = r|(p&q);
//6
p = *(a+i*k+l)&0b00000000000000000000110000000000;
q = *(b+l*n+j)&0b00000000000000000000110000000000;
r = r|(p&q);
//7
p = *(a+i*k+l)&0b00000000000000000011000000000000;
q = *(b+l*n+j)&0b00000000000000000011000000000000;
r = r|(p&q);
//8
p = *(a+i*k+l)&0b00000000000000001100000000000000;
q = *(b+l*n+j)&0b00000000000000001100000000000000;
r = r|(p&q);
//9
p = *(a+i*k+l)&0b00000000000000110000000000000000;
q = *(b+l*n+j)&0b00000000000000110000000000000000;
r = r|(p&q);
//10
p = *(a+i*k+l)&0b00000000000011000000000000000000;
q = *(b+l*n+j)&0b00000000000010000000000000000000;
r = r|(p&q);
//11
p = *(a+i*k+l)&0b00000000001100000000000000000000;
q = *(b+l*n+j)&0b00000000001100000000000000000000;
r = r|(p&q);
//12
p = *(a+i*k+l)&0b00000000110000000000000000000000;
q = *(b+l*n+j)&0b00000000110000000000000000000000;
r = r|(p&q);
//13
p = *(a+i*k+l)&0b00000011000000000000000000000000;
q = *(b+l*n+j)&0b00000011000000000000000000000000;
r = r|(p&q);
//14
p = *(a+i*k+l)&0b00001100000000000000000000000000;
q = *(b+l*n+j)&0b00001100000000000000000000000000;
r = r|(p&q);
//15
p = *(a+i*k+l)&0b00110000000000000000000000000000;
q = *(b+l*n+j)&0b00110000000000000000000000000000;
r = r|(p&q);
//16
p = *(a+i*k+l)&0b11000000000000000000000000000000;
q = *(b+l*n+j)&0b11000000000000000000000000000000;
r = r|(p&q);
//packing
*(c+i*n+j)=+r;
}
}
}
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
printf("fun() took %f seconds to execute \n", time_taken);
return 0;
}