-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.hpp
63 lines (51 loc) · 1.56 KB
/
matrix.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by bosco on 21/09/22.
//
#ifndef LAB1TEMPLATE_MATRIX_HPP
#define LAB1TEMPLATE_MATRIX_HPP
#include <vector>
#include <stdexcept>
#include <cmath>
#include <iostream>
using namespace std;
constexpr double TOLERANCE = 0.0001;
/**
* A container for the size of a matrix
*/
struct MatrixSize {
int rows;
int cols;
};
class Matrix {
private:
vector<vector<double>> matrix;
public:
Matrix(): matrix{{0}} {};
explicit Matrix(int n);
Matrix(int r, int c);
explicit Matrix(const vector<double> &v);
Matrix(const Matrix& m);
~Matrix();
MatrixSize getSize() const;
void setValue(int row, int col, double val);
double getValue(int row, int col) const;
void clear();
friend ostream & operator << (ostream &out, const Matrix &m);
friend bool operator== (const Matrix& lhs, const Matrix& rhs);
friend bool operator!= (const Matrix& lhs, const Matrix& rhs) { return !(lhs == rhs); }
Matrix& operator++();
Matrix operator++(int);
Matrix& operator--();
Matrix operator--(int);
Matrix& operator=(Matrix rhs);
friend void mySwap(Matrix& m1, Matrix& m2);
Matrix& operator+=(const Matrix& rhs);
friend Matrix operator+(Matrix lhs, const Matrix& rhs);
Matrix& operator-=(const Matrix& rhs);
friend Matrix operator-(Matrix lhs, const Matrix& rhs);
Matrix& operator*=(const Matrix& rhs);
friend Matrix operator*(Matrix lhs, const Matrix& rhs);
Matrix& operator*=(const double rhs);
friend Matrix operator*(Matrix lhs, const double rhs);
};
#endif //LAB1TEMPLATE_MATRIX_HPP