-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.h
52 lines (43 loc) · 1.43 KB
/
matrix.h
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
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef MATRIX_H
#define MATRIX_H
#ifdef _WIN32
#define MATRIX_API __declspec(dllexport)
#else
#define MATRIX_API
#endif
#include <vector>
#include <cstddef>
class MATRIX_API Matrix {
public:
Matrix();
Matrix(size_t rows, size_t cols);
Matrix(const Matrix& other);
Matrix(Matrix&& other) noexcept;
~Matrix();
double get(size_t row, size_t col) const;
void set(size_t row, size_t col, double value);
size_t rows() const;
size_t cols() const;
void fill(double value);
Matrix operator*(const Matrix& other) const;
Matrix operator+(const Matrix& other) const;
Matrix operator-(const Matrix& other) const;
Matrix operator*(double scalar) const;
Matrix elementwise_multiplication(const Matrix& other) const;
Matrix transpose() const;
private:
size_t rows_, cols_;
std::vector<double> data_;
};
extern "C" {
MATRIX_API Matrix* Matrix_new(size_t rows, size_t cols);
MATRIX_API void Matrix_delete(Matrix* m);
MATRIX_API double Matrix_get(const Matrix* m, size_t row, size_t col);
MATRIX_API void Matrix_set(Matrix* m, size_t row, size_t col, double value);
MATRIX_API size_t Matrix_rows(const Matrix* m);
MATRIX_API size_t Matrix_cols(const Matrix* m);
MATRIX_API void Matrix_fill(Matrix* m, double value);
MATRIX_API Matrix* Matrix_multiply(const Matrix* a, const Matrix* b);
MATRIX_API Matrix* Matrix_transpose(const Matrix* m);
}
#endif // MATRIX_H