This repository was archived by the owner on Jul 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix.hpp
More file actions
55 lines (45 loc) · 1.6 KB
/
matrix.hpp
File metadata and controls
55 lines (45 loc) · 1.6 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Matrix{
public:
// constructors
Matrix(int m, int n);
Matrix(const Matrix&);
Matrix(int m, int n, double** refd);
Matrix(int m);
// destructor
~Matrix();
// standard matrix operations
Matrix& operator=(const Matrix&);
Matrix& operator+=(const Matrix&);
Matrix& operator-=(const Matrix&);
Matrix& operator*=(const Matrix&);
Matrix& operator*=(double);
// other matrix operations
Matrix transpose();
Matrix slice(int m, int m1, int n, int n1);
// helper functions
inline int get_rows() {return m_rows;}
inline int get_cols() {return n_cols;}
inline double operator()(int i, int j) {return data[i][j];}
void assign_random();
void assign_triangular();
void assign_zeros();
void print();
double* get_column(int j);
// static helper functions
static double inner_product(int n, double* v1, double* v2);
static void vector_matrix_mul(double* v, Matrix A, double * & v_out);
static double* matrix_vector_mul(Matrix A, double* v);
static Matrix strassen(Matrix A, Matrix B);
private:
int m_rows;
int n_cols;
double ** data;
void alloc_space();
bool is_submatrix = false;
};
// some static methods for Matrix Class
Matrix operator+(const Matrix&, const Matrix&);
Matrix operator-(const Matrix&, const Matrix&);
Matrix operator*(const Matrix&, const Matrix&);
Matrix operator*(const Matrix&, double);
Matrix operator*(double, const Matrix&);