aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-06-12 19:05:34 +0100
committerYann Herklotz <git@yannherklotz.com>2020-06-12 19:05:34 +0100
commit8e3c89bad3a20c0bb9c88b83d966565d79822ff1 (patch)
treeb5f3b2ce03bf9b233fd2e907668e6c8d104be0dc /test
parentc6f390beecfbd8d749d06e8d9b86a7754a2239c5 (diff)
downloadvericert-8e3c89bad3a20c0bb9c88b83d966565d79822ff1.tar.gz
vericert-8e3c89bad3a20c0bb9c88b83d966565d79822ff1.zip
Update matrix and use 32 bit
Diffstat (limited to 'test')
-rw-r--r--test/matrix.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/test/matrix.c b/test/matrix.c
index 2a1a6b7..d612734 100644
--- a/test/matrix.c
+++ b/test/matrix.c
@@ -1,8 +1,10 @@
-void matrix_multiply(int first[][2], int second[][2], int multiply[][2], int m, int q, int p) {
+#define N 4
+
+void matrix_multiply(int first[][N], int second[][N], int multiply[][N]) {
int sum = 0;
- for (int c = 0; c < m; c++) {
- for (int d = 0; d < q; d++) {
- for (int k = 0; k < p; k++) {
+ for (int c = 0; c < N; c++) {
+ for (int d = 0; d < N; d++) {
+ for (int k = 0; k < N; k++) {
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
@@ -12,10 +14,10 @@ void matrix_multiply(int first[][2], int second[][2], int multiply[][2], int m,
}
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}};
+ int f[N][N] = {{1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4}};
+ int s[N][N] = {{5, 6, 7, 8}, {5, 6, 7, 8}, {5, 6, 7, 8}, {5, 6, 7, 8}};
+ int m[N][N] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
- matrix_multiply(f, s, m, 2, 2, 2);
+ matrix_multiply(f, s, m);
return m[1][1];
}