-
Notifications
You must be signed in to change notification settings - Fork 0
/
myMatrix.hpp
69 lines (50 loc) · 2.28 KB
/
myMatrix.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
59
60
61
62
63
64
65
66
67
68
69
/**
* Definition of derived Matrix class.
*/
#ifndef MYMATRIX_H
#define MYMATRIX_H
#ifndef AUXILIARY_H
#include "auxiliary.hpp"
#endif
#ifndef MYVECTOR_H
#include "myVector.hpp"
#endif
#include <cassert>
template<typename T>
class myMatrix : public myVector<T>
{
public:
myMatrix(const size_t rows, const size_t cols);
myMatrix(const myMatrix<T>& otherMat);
myMatrix(myMatrix<T>&& otherMat);
myMatrix<T>& operator= (const myMatrix<T>& otherMat);
myMatrix<T>& operator<< (T val);
template <typename U> friend myMatrix<U> operator+ (const myMatrix<U>& otherMat);
template <typename U> friend myMatrix<U> operator+ (const myMatrix<U>& Mat1, const myMatrix<U>& Mat2);
myMatrix<T>& operator+= (const myMatrix<T>& otherMat);
template <typename U> friend myMatrix<U> operator- (const myMatrix<U>& otherMat);
template <typename U> friend myMatrix<U> operator- (const myMatrix<U>& Mat1, const myMatrix<U>& Mat2);
myMatrix<T>& operator-= (const myMatrix<T>& otherMat);
template <typename U> friend myMatrix<U> operator* (const myMatrix<U>& Mat, const U coeff);
template <typename U> friend myMatrix<U> operator* (const U coeff, const myMatrix<U>& Mat);
myMatrix<T>& operator*= (const T coeff);
template <typename U> friend myMatrix<U> operator* (const myMatrix<U>& Mat1, const myMatrix<U>& Mat2);
myMatrix<T>& operator*= (const myMatrix<T>& otherMat);
template <typename U> friend myMatrix<U> operator/ (const myMatrix<U>& Mat, const U divisor);
myMatrix<T>& operator/= (const T divisor);
myMatrix<T> block(const size_t minRowIdx, const size_t minColIdx,
const size_t rows, const size_t cols) const;
myMatrix<T> concatenateVert(const myMatrix<T>& Mat1, const myMatrix<T>& Mat2);
myMatrix<T>& concatenateVert(const myMatrix<T>& otherMat);
myMatrix<T> concatenateHoriz(const myMatrix<T>& Mat1, const myMatrix<T>& Mat2);
myMatrix<T>& concatenateHoriz(const myMatrix<T>& otherMat);
T getValue(const size_t rowIdx, const size_t colIdx) const;
void setValue(const size_t rowIdx, const size_t colIdx, const T val);
size_t nrows() const;
size_t ncols() const;
void print() const override;
private:
size_t myRows = 0;
size_t myCols = 0;
};
#endif