aboutsummaryrefslogtreecommitdiff
path: root/fptr_ast/common.h
blob: 4812b59fce2298dbcb10732ea7d44b0dcd711b84 (plain) (blame)
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
27
28
29
30
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 */