-
Notifications
You must be signed in to change notification settings - Fork 0
/
6quant.c
65 lines (63 loc) · 1.63 KB
/
6quant.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
#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);
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));
srand(time(0));
for(i=0;i<m;i++){
for(j=0;j<k;j++){
*(a+i*k+j)=rand();
}
}
for(i=0;i<k;i++){
for(j=0;j<n;j++){
*(b+i*n+j)=rand();
}
}
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)&0b00000000000000000000000000111111;
q = *(b+l*n+j)&0b00000000000000000000000000111111;
r = r|(p&q);
//2
p = *(a+i*k+l)&0b00000000000000000000111111000000;
q = *(b+l*n+j)&0b00000000000000000000111111000000;
r = r|(p&q);
//3
p = *(a+i*k+l)&0b00000000000000111111000000000000;
q = *(b+l*n+j)&0b00000000000000111111000000000000;
r = r|(p&q);
//4
p = *(a+i*k+l)&0b00000000111111000000000000000000;
q = *(b+l*n+j)&0b00000000111111000000000000000000;
r = r|(p&q);
//5
p = *(a+i*k+l)&0b00111111000000000000000000000000;
q = *(b+l*n+j)&0b00111111000000000000000000000000;
r = r|(p&q);
//packing
*(c+i*n+j)=+r;
}
}
}
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
printf("took %f seconds to execute \n", time_taken);
return 0;
}