-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyMatrix.h
46 lines (38 loc) · 1.13 KB
/
MyMatrix.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
#pragma once
#include <iostream>
using namespace std;
class MyMatrix {
private:
double** _matrix;
int _m;
int _n;
// setters
void setM(int m) { this->_m = m; }
void setN(int n) { this->_n = n; }
void setMatrix(double** matrix) { this->_matrix = matrix; }
// delete matrix
void clear();
public:
// constractors and destructor
MyMatrix(const MyMatrix& other);
MyMatrix(int m, int n);
MyMatrix();
~MyMatrix();
// getters
int getM() const { return _m; }
int getN() const { return _n; }
double** getMatrix() const { return _matrix; }
// operators
MyMatrix operator+(const MyMatrix& other) const;
MyMatrix operator-(const MyMatrix& other) const;
MyMatrix operator*(const MyMatrix& other) const;
MyMatrix operator*(double scalar) const; // mul from right
MyMatrix& operator=(const MyMatrix& other);
bool operator==(const MyMatrix& other) const;
double* operator[](int i) const;
operator double() const;
// friends
friend MyMatrix operator*(double scalar, const MyMatrix& matrix); // mul from left
friend ostream& operator<<(ostream& out, const MyMatrix& matrix);
friend istream& operator>>(istream& out, MyMatrix& matrix);
};