-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMatrix.h
More file actions
40 lines (28 loc) · 983 Bytes
/
Matrix.h
File metadata and controls
40 lines (28 loc) · 983 Bytes
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
32
33
34
35
36
37
38
39
40
#ifndef MATRIX_H_
#define MATRIX_H_
#include <stdint.h>
#define MATRIX_ARITH_BEGIN __start_Matrix_Arith
#define MATRIX_ARITH_END __stop_Matrix_Arith
#define MATRIX_INITIALIZER(X, ROW, COLUMN) \
Matrix_Initializer(&(X) ,(ROW), (COLUMN))
#define autofree \
__attribute__((cleanup(Matrix_Free)))
enum { NAIVE_ARITHMETIC, };
typedef struct _Matrix {
uint32_t row;
uint32_t column;
int **values;
int **(*New)(uint32_t row, uint32_t column);
void (*Delete)(void *);
} Matrix;
typedef struct _Matrix_Arith {
Matrix (*Addition)(Matrix, const Matrix, const Matrix);
Matrix (*Subtract)(Matrix, const Matrix, const Matrix);
Matrix (*Multiply)(Matrix, const Matrix, const Matrix);
} Matrix_Arith;
void Matrix_Initializer(Matrix *, uint32_t, uint32_t);
void Matrix_Free(void *);
extern Matrix_Arith Naive_Matrix_Arith;
extern Matrix_Arith __start_Matrix_Arith[];
extern Matrix_Arith __stop_Matrix_Arith[];
#endif /* MATRIX_H_ */