-
Notifications
You must be signed in to change notification settings - Fork 0
/
8quant.c
62 lines (60 loc) · 1.58 KB
/
8quant.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
#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)&0b00000000000000000000000011111111;
q = *(b+l*n+j)&0b00000000000000000000000011111111;
r = r|(p&q);
//2
p = *(a+i*k+l)&0b00000000000000001111111100000000;
q = *(b+l*n+j)&0b00000000000000001111111100000000;
r = r|(p&q);
//3
p = *(a+i*k+l)&0b00000000111111110000000000000000;
q = *(b+l*n+j)&0b00000000111111110000000000000000;
r = r|(p&q);
//4
p = *(a+i*k+l)&0b11111111000000000000000000000000;
q = *(b+l*n+j)&0b11111111000000000000000000000000;
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;
}