aboutsummaryrefslogtreecommitdiffstats
path: root/test/matrix.c
blob: 2a1a6b7d84c7ae988b4dc598bb07da84283557e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void matrix_multiply(int first[][2], int second[][2], int multiply[][2], int m, int q, int p) {
    int sum = 0;
    for (int c = 0; c < m; c++) {
        for (int d = 0; d < q; d++) {
            for (int k = 0; k < p; k++) {
                sum = sum + first[c][k]*second[k][d];
            }
            multiply[c][d] = sum;
            sum = 0;
        }
    }
}

int main() {
    int f[2][2] = {{1, 2}, {3, 4}};
    int s[2][2] = {{1, 2}, {3, 4}};
    int m[2][2] = {{0, 0}, {0, 0}};

    matrix_multiply(f, s, m, 2, 2, 2);
    return m[1][1];
}