diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-31 14:25:07 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-31 14:25:07 +0300 |
commit | a0c6ff2c222beb72493f2e40ed27492061dfdf22 (patch) | |
tree | a3a8c8279135fb92e3032dc85e9e4c6a06ca71e2 /fptr_ast/common.h | |
download | playground-a0c6ff2c222beb72493f2e40ed27492061dfdf22.tar.gz playground-a0c6ff2c222beb72493f2e40ed27492061dfdf22.zip |
initial fptr ast programs
Diffstat (limited to 'fptr_ast/common.h')
-rw-r--r-- | fptr_ast/common.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fptr_ast/common.h b/fptr_ast/common.h new file mode 100644 index 0000000..4812b59 --- /dev/null +++ b/fptr_ast/common.h @@ -0,0 +1,31 @@ +#ifndef COMMON_H +#define COMMON_H + +#include <stdint.h> +#include <stddef.h> + +#define MATRIX_SIZE 100 + +static inline void init_matrices(intptr_t *A, intptr_t *B) +{ + int counter = 0; + for (size_t i = 0; i < MATRIX_SIZE; ++i) + for (size_t j = 0; j < MATRIX_SIZE; ++j) { + A[i * MATRIX_SIZE + j] = counter; + B[i * MATRIX_SIZE + j] = counter; + counter++; + } +} + +static inline size_t hash(intptr_t *C) +{ + size_t h = 0; + for (size_t i = 0; i < MATRIX_SIZE; ++i) + for (size_t j = 0; j < MATRIX_SIZE; ++j) { + h += C[i * MATRIX_SIZE + j]; + } + + return h; +} + +#endif /* COMMON_H */ |