-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSparse_Matrix.h
More file actions
35 lines (30 loc) · 1.01 KB
/
Copy pathSparse_Matrix.h
File metadata and controls
35 lines (30 loc) · 1.01 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
/*
* John Deters
* Sparse Matrix.h
*/
#include <map>
#include <initializer_list>
#include <sstream>
#ifndef SPARSE_MATRIX_H
#define SPARSE_MATRIX_H
struct SparseMatrix{
private:
std::map <std::pair<long, long>, long> pos_;
long dim_x_, dim_y_;
public:
SparseMatrix(long x, long y){dim_x_ = x; dim_y_ = y;};
SparseMatrix(long, long, std::initializer_list<long>);
void set (long, long, long);
std::pair<long, long> dimensions();
long element_count();
long operator()(long, long);
friend SparseMatrix operator+(SparseMatrix, long);
friend SparseMatrix operator+(long, SparseMatrix);
friend SparseMatrix operator+(SparseMatrix, SparseMatrix);
friend std::ostream &operator<<(std::ostream &, SparseMatrix);
friend SparseMatrix operator*(SparseMatrix, long);
friend SparseMatrix operator*(long, SparseMatrix);
friend SparseMatrix operator*(SparseMatrix, SparseMatrix);
};
std::ostream &operator<<(std::ostream &, SparseMatrix);
#endif /* SPARSE_MATRIX_H */