-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix.h
100 lines (66 loc) · 2.02 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef MATRIX_H
#define MATRIX_H
#include <iostream>
using namespace std;
template <typename T>
class Matrix;
template <typename T>
ostream& operator<<(ostream&, const Matrix<T>&);
template <typename T>
class Matrix
{
private:
//Vars
T** matrix;
public:
//Matrix Width and Height
int m; //Rows
int n; //Cols
//Default Constructor
Matrix();
//Constructor
Matrix(const int rows, const int cols);
//Copy Constructor
Matrix(const Matrix<T>& A);
//Destructor
~Matrix();
//Assignment operator overload
Matrix<T>& operator=(const Matrix<T>& A);
//Operator overload to print
friend ostream& operator<< <T> (ostream& os, const Matrix<T>& matrix);
/*
* MEMBER FUNCTIONS & MATRIX ARITHMETIC
*/
void insertVal(T& val, int row, int col);
T& getVal(int row, int col) const;
//Arithmetic matrix operations
Matrix<T>& operator+(const Matrix<T>& A);
Matrix<T>& operator-(const Matrix<T>& A);
Matrix<T>& operator*(const Matrix<T>& A);
Matrix<T>& operator*(const T& val);
//Matrix operations
void transpose();
bool invert();
void gaussjordan();
T determinant();
int rowechelon();
void augmentmatrix(const Matrix<T>& A);
void eigenvectors();
T dotproduct(const Matrix<T>& b);
//The columns of matrix p must be orthorogonal for this to work ATM
Matrix<T>& project(const Matrix<T>& p);
void gramschmidt();
/*
* Prints results, doesn't affect calling object
*/
void columnspace() const;
void nullspace() const;
void solvematrix(const Matrix<T>& b) const;
private:
//Private Functions
void row_replacement(const int row1, const int row2, const T& k);
void row_interchange(const int row1, const int row2);
void row_scaling(const int row1, const T& k);
};
#include "matrix_funcs.hpp"
#endif