-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matrix.h
146 lines (118 loc) · 5.55 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*===============================================================================
FILE: Matrix.h
DESCRIPTION: This header file creates the Classes used for Matrices
COMPILER: Linux GNU g++ compiler c++ -std=c++11
using custom makefile and Clion IDE editor
NOTES: Matrix_ops inherits from Matrix class and Stuff class just contains the stuff used
in the Driver
Matrix has protected members so Matrix_ops can inherit, so no private members
MODIFICATION HISTORY:
Author Date Version
--------------- ---------- --------------
Shawn Ray 2017-04-13 Version 1.0 started project
Shawn Ray 2017-04-14 Version 1.1
Shawn Ray 2017-04-15 Version 1.2 overloaded operators
Shawn Ray 2017-04-16 Version 1.3 added class definition
for command line stuffs
Shawn Ray 2017-04-17 Version 1.4 Template class
Shawn Ray 2017-04-18 Version 1.5
Shawn Ray 2017-04-19 Version 1.6 fixed bugged
Shawn Ray 2017-04-20 Version 1.7 templates
Shawn Ray 2017-04-21 Version 1.8 inheritance
Shawn Ray 2017-04-22 Version 1.9
Shawn Ray 2017-04-23 Version 2.0 member function, trans/multi
Shawn Ray 2017-04-24 Version 2.1 member function for det
Shawn Ray 2017-04-25 Version 2.2
Shawn Ray 2017-04-26 Version 2.3
Shawn Ray 2017-04-27 Version 2.4 cleaned up code
Shawn Ray 2017-04-28 Version 2.5 added Clear and resize functions
clear clears the memory and resize resizes
a class object
Shawn Ray 2017-04-29 Version 2.6
Shawn Ray 2017-04-30 Version 2.7
Shawn Ray 2017-05-01 Version 2.8 virtual destruction
Shawn Ray 2017-05-02 Version 2.9
Shawn Ray 2017-05-03 Version 3.0 worked on reduced row
Shawn Ray 2017-05-04 Version 3.1 added output file member
Shawn Ray 2017-05-05 Version 3.2 Worked on completing the inverse
================================================================================*/
#ifndef PROJ3_MATRIX_H
#define PROJ3_MATRIX_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
/*===============================================================================
CLASS: Matrix{};
DESCRIPTION: This class declares the variables and basic operations to be used
for matrix objects
NOTES: templated class type
===============================================================================*/
template<typename T>
class Matrix {
protected:
int rows;
int cols;
T **array;
T deter;
void resize(const int&, const int&, bool = true);
void clear();
public:
Matrix(); // default constructor
Matrix(int, int); // overloaded constructor
Matrix(const Matrix<T> &); // copy constructor
template<typename U>
friend std::istream& operator >> (std::istream &, Matrix<U> &);
template<typename U>
friend std::ostream& operator << (std::ostream &, const Matrix<U> &);
Matrix<T>& operator = (const Matrix<T> &);
virtual ~Matrix();
};
/*===============================================================================
CLASS: Matrix_ops{};
CLASS DEPENDANT: Matrix{};
DESCRIPTION: This class sets forth the ground work for arithmetical operations
to be enacted on the objects in the file
NOTES: Inherits information and behaviour from Matrix class, and templated class
=============================================================================== */
template<typename T>
class Matrix_ops : public Matrix<T>
{
public:
Matrix_ops(int, int); // intialized constructor
Matrix_ops(const Matrix_ops<T> &); // initialized copy constructor
Matrix_ops<T> operator + (const Matrix_ops<T> &) const;
Matrix_ops<T> operator - (const Matrix_ops<T> &) const;
Matrix_ops<T> operator * (const Matrix_ops<T> &) const;
bool operator == (const Matrix_ops<T> &) const;
Matrix_ops<T> trans() const;
T det();
Matrix_ops<T> inv();
Matrix_ops<T> reduced_row();
Matrix_ops<T>& div_row(int, T);
Matrix_ops<T>& sub_row(int);
Matrix_ops<T> solve() const;
Matrix_ops<T>& out_file(char []);
};
/*===============================================================================
CLASS: Stuff{};
DESCRIPTION: This class just lays down the ground work for the variables used
inside of matrix_math.cpp
NOTES: templated class
===============================================================================*/
class Stuff{
public:
int m;
int n;
int position;
char let_x;
char file1[20];
std::ifstream infile;
};
//function declarations
template<typename T> T expo(const T &, const T &); // to replace the pow function
bool test_arg(int, Stuff &);
void compare_arg(int, char * [], Stuff &);
template<typename T> T open_file(int, char * [], Stuff &);
void help();
#endif //PROJ3_MATRIX_H