~martijnbraam/megapixels

ref: 95cfc652c8d76434093e43b3afcdadc68cd37983 megapixels/src/matrix.c -rw-r--r-- 516 bytes
95cfc652Martijn Braam Matrix cleanup 1 year, 3 months ago
                                                                                
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
#include <stdio.h>

void
print_matrix(float m[9])
{
	printf(" [%.2f  %.2f  %.2f] \n", m[0], m[1], m[2]);
	printf(" [%.2f  %.2f  %.2f] \n", m[3], m[4], m[5]);
	printf(" [%.2f  %.2f  %.2f] \n\n", m[6], m[7], m[8]);
}

void
multiply_matrices(float a[9], float b[9], float out[9])
{
	// zero out target matrix
	for (int i = 0; i < 9; i++) {
		out[i] = 0;
	}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				out[i * 3 + j] += a[i * 3 + k] * b[k * 3 + j];
			}
		}
	}
}