diff options
Diffstat (limited to 'fptr_ast/ref.c')
-rw-r--r-- | fptr_ast/ref.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fptr_ast/ref.c b/fptr_ast/ref.c new file mode 100644 index 0000000..6169a25 --- /dev/null +++ b/fptr_ast/ref.c @@ -0,0 +1,33 @@ +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> +#include "common.h" + +static void matrix_mult(intptr_t *A, intptr_t *B, intptr_t *C) +{ + for (size_t i = 0; i < MATRIX_SIZE; ++i) + for (size_t j = 0; j < MATRIX_SIZE; ++j) { + intptr_t r = 0; + for (size_t k = 0; k < MATRIX_SIZE; ++k) + r += A[i * MATRIX_SIZE + k] * B[k * MATRIX_SIZE + j]; + + C[i * MATRIX_SIZE + j] = r; + } +} + +int main() +{ + + intptr_t *A = calloc(MATRIX_SIZE * MATRIX_SIZE, sizeof(intptr_t)); + assert(A); + + intptr_t *B = calloc(MATRIX_SIZE * MATRIX_SIZE, sizeof(intptr_t)); + assert(B); + + intptr_t *C = calloc(MATRIX_SIZE * MATRIX_SIZE, sizeof(intptr_t)); + assert(C); + + init_matrices(A, B); + matrix_mult(A, B, C); + printf("%zu\n", hash(C)); +} |