-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrices.hpp
30 lines (25 loc) · 947 Bytes
/
matrices.hpp
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
#ifndef MATRICES_HPP
#define MATRICES_HPP
#include <vector>
#include <ostream>
class Matrix {
public:
Matrix(int rows, int cols); // random matrix
Matrix(std::initializer_list<std::initializer_list<float>> list); // user-specified matrix
Matrix(int rows, int cols, float value); // constant matrix
Matrix multiply(const Matrix& other) const;
Matrix add(const Matrix& other) const;
Matrix subtract(const Matrix& other) const;
Matrix elementwise_multiply(const Matrix& other) const;
Matrix operator+(const Matrix& other) const;
Matrix operator-(const Matrix& other) const;
Matrix operator*(const Matrix& other) const;
int getNumRows() const;
int getNumColumns() const;
float get(unsigned row, unsigned col) const;
void set(unsigned row, unsigned col, float value);
private:
std::vector<std::vector<float>> data;
float random_float(float min, float max);
};
#endif // MATRICES_HPP