-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.h
More file actions
50 lines (40 loc) · 1.29 KB
/
Matrix.h
File metadata and controls
50 lines (40 loc) · 1.29 KB
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
#pragma once
#include <vector>
class Matrix
{
public:
struct Shape
{
size_t rows;
size_t columns;
};
Matrix(const Shape & shape);
Matrix(size_t rows, size_t columns);
Matrix(const std::vector<std::vector<double>> & data);
Matrix(std::vector<std::vector<double>> && data);
Matrix(const std::vector<double> & data);
Matrix(const Matrix & other);
Matrix & operator=(const Matrix & other);
Matrix & operator=(Matrix && other);
double & operator()(size_t x, size_t y);
const double & operator()(size_t x, size_t y) const;
Matrix & operator+=(const Matrix & other);
Matrix & operator-=(const Matrix & other);
Matrix & operator*=(double scalar);
Matrix & operator/=(double scalar);
Matrix & operator+(const Matrix & other);
Matrix & operator-(const Matrix & other);
Matrix & operator*(double scalar);
Matrix & operator/(double scalar);
Matrix operator*(const Matrix & other) const;
Matrix transpose() const;
Matrix hadamardProduct(const Matrix & other) const;
friend std::ostream & operator<<(std::ostream & stream, const Matrix & matrix);
friend std::istream & operator>>(std::istream & stream, Matrix & matrix);
size_t GetNumberOfRows() const;
size_t GetNumberOfColumns() const;
Shape GetShape() const;
void Reset(double value);
private:
std::vector<std::vector<double>> m_data;
};