Naively computes dst = a * b, where a is a matrix of size YxI, and b is a matrix of size IxX. The output matrix dst will be of size YxX.
| 9 | |
| 10 | // Naively computes dst = a * b, where a is a matrix of size YxI, and b is a matrix of size IxX. The output matrix dst will be of size YxX. |
| 11 | void mul(float *dst, float *a, float *b, int Y, int I, int X) |
| 12 | { |
| 13 | for(int y = 0; y < Y; ++y) |
| 14 | { |
| 15 | for(int x = 0; x < X; ++x) |
| 16 | { |
| 17 | float *A = a; |
| 18 | float *AEnd = a + I; |
| 19 | float *B = b + x; |
| 20 | float acc = 0.f; |
| 21 | while(A < AEnd) |
| 22 | { |
| 23 | acc += *A++ * *B; |
| 24 | B += X; |
| 25 | } |
| 26 | *dst++ = acc; |
| 27 | } |
| 28 | a += I; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | float Sum(float *m, int A, int B) |
| 33 | { |