-
Notifications
You must be signed in to change notification settings - Fork 0
/
testmat.c
68 lines (54 loc) · 1.39 KB
/
testmat.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
#include <stdio.h>
extern void dctdlt(unsigned int n, unsigned int stride_in, const double* dct,
unsigned int stride_out, double* dlt);
extern void dltdct(unsigned int n, unsigned int stride_in, const double* dlt,
unsigned int stride_out, double* dct);
static const int n = 10;
int main()
{
double I[n*n];
double M[n*n];
double L[n*n];
unsigned int i, j, k;
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
I[i*n+j] = (i == j);
M[i*n+j] = i*j;
L[i*n+j] = i*j;
}
}
for (j = 0; j < n; ++j)
dltdct(n, n, I+j, n, M+j);
for (j = 0; j < n; ++j)
dctdlt(n, n, I+j, n, L+j);
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
I[i*n+j] = 0;
for (k = 0; k < n; ++k) {
I[i*n+j] += M[i*n+k]*L[k*n+j];
}
}
}
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
printf(" % .4f", M[i*n+j]);
}
printf("\n");
}
printf("\n");
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
printf(" % .4f", L[i*n+j]);
}
printf("\n");
}
printf("\n");
for (i = 0; i < n; ++i) {
for (j = 0; j < n; ++j) {
printf(" % .4f", I[i*n+j]);
}
printf("\n");
}
printf("\n");
return 0;
}