-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatrixPP.hpp
58 lines (43 loc) · 1.16 KB
/
MatrixPP.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
#include <vector>
#include <math.h>
#include <algorithm>
#include <numeric>
#define _PP_USE_THREADS
#ifdef _PP_USE_THREADS
#include <Windows.h>
#endif
#define _DEBUG
#ifdef _DEBUG
#include <iostream>
#endif
typedef long double NINT; //matrix double
typedef struct Shape {
unsigned int rows, cols;
};
typedef class Matrix {
private:
std::vector<std::vector<NINT>> rows{};
Shape shape;
public:
/* possible constructors */
/* 3d/full matrix */
Matrix(std::vector<std::vector<NINT>> fullmatrix) {
rows = fullmatrix;
sh();
}//3d
void sh(); //set the shape
void T(); //transpose
bool is_square() { return (shape.rows == shape.cols); }
unsigned int get_rows() { return shape.rows; }
unsigned int get_cols() { return shape.cols; }
NINT determinant();
NINT tr();
std::vector<std::vector<NINT>> grab_matrix() { return rows; } //debug
Matrix operator+(const Matrix); //add 2 matrices
Matrix operator-(const Matrix); //sub 2 matrices
Matrix operator*(const Matrix); //multiply 2 matrices
Matrix operator+(const NINT); //add 2 matrices
Matrix operator-(const NINT); //sub 2 matrices
Matrix operator*(const NINT); //multiply 2 matrices
};
NINT trace(Matrix);