-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.h
75 lines (58 loc) · 1.68 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//Header de la classe matrix
#ifndef MATRIXHEADERDEF
#define MATRIXHEADERDEF
#include "csrmatrix.h"
#include "vector.h"
class Matrix{
private:
double** mData;
int mNumRows;
int mNumCols;
public:
//Constructors and destructors
Matrix(const Matrix& otherMatrix);
Matrix(const Vector& V);
Matrix(int size);
Matrix(int rows, int cols);
~Matrix();
//Private variables accessing
int GetNumberOfRows() const;
int GetNumberOfCols() const;
double& operator()(int i, int j);
//Operator Overloading
Matrix& operator=(const Matrix& otherMatrix);
Matrix operator+() const;
Matrix operator+(const Matrix& m) const;
Matrix operator-() const;
Matrix operator-(const Matrix& m) const;
Matrix operator*(double a) const;
Matrix operator*(const Matrix& m) const;
//Appending, size modifications
void resize(int newRows, int newCols);
void delRow(int nRowsToDel=1);
void addRow(int nRowsToAdd=1);
void addCol(int nColsToAdd=1);
void delCol(int nColsToDel=1);
void addRow(const Vector& newRow);
void addCol(const Vector& newCol);
//Extracting
Vector row(int row);
Vector col(int col);
//Friend functions
//Identity
friend Matrix ID(int size, double val=1.0);
friend Matrix ID(const Vector& V);
//Vector multiplication
friend Vector operator*(const Matrix& m, const Vector& v);
friend Vector operator *(const Vector& v, const Matrix& m);
//Other functions
void write(string fileName) const;
//CSRMatrix class as a friend
friend class CSRMatrix;
};
//Friend functions
Matrix ID(int size, double val);
Matrix ID(const Vector& V);
Vector operator*(const Matrix& m, const Vector& v);
Vector operator*(const Vector& v, const Matrix& m);
#endif