-
Notifications
You must be signed in to change notification settings - Fork 0
/
SparseMatrix.h
56 lines (49 loc) · 1.56 KB
/
SparseMatrix.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
#include "vector"
#include "string"
using namespace std;
struct MatrixEntry{
int row;
int column;
double value;
};
class SparseMatrix {
MatrixEntry* entries;
int capacity;
int entriesSize;
int rowSize;
int colSize;
void init();
MatrixEntry* getEntry(int column, int row);
void push(int column, int row, double val);
void add(int column, int row, double val);
void subtract(int column, int row, double val);
void multiply(int column, int row, double val);
void divide(int column, int row, double val);
SparseMatrix* getTransposedMatrix();
void assureThatSquare();
SparseMatrix* getMatrixWithStrippedColumnAndRow(int, int);
void printMatrix(ostream&)const;
public:
SparseMatrix();
SparseMatrix(SparseMatrix &original);
virtual ~SparseMatrix();
double& operator()(int col, int row);
SparseMatrix* operator+(const SparseMatrix&);
SparseMatrix* operator+(const double);
SparseMatrix* operator-(const SparseMatrix&);
SparseMatrix* operator-(const double);
SparseMatrix* operator*(const SparseMatrix&);
SparseMatrix* operator*(const double);
SparseMatrix* operator!();
SparseMatrix* operator/(const SparseMatrix&);
friend ostream& operator<<(ostream& os, const SparseMatrix&);
friend ostream& operator<<(ostream& os, const SparseMatrix*);
double getAlgebraicComplement(int col, int row);
double countDet();
SparseMatrix* getComplementaryMatrix();
int rows();
int cols();
int size();
bool diag();
SparseMatrix* shift(int, int);
};