-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.cpp
46 lines (38 loc) · 865 Bytes
/
matrix.cpp
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
#include "matrix.h"
using namespace std;
Matrix operator *(float re, Matrix& yourMatrix)
{
Matrix result(yourMatrix.row, yourMatrix.col, 0);
for (int i = 0; i < yourMatrix.row; i++)
{
for (int j = 0; j < yourMatrix.col; j++)
{
result.myMatrix[i][j] = yourMatrix(i, j) * re;
}
}
return result;
}
Matrix operator *( Matrix& yourMatrix,float re)
{
Matrix result(yourMatrix.row, yourMatrix.col, 0);
for (int i = 0; i < yourMatrix.row; i++)
{
for (int j = 0; j < yourMatrix.col; j++)
{
result.myMatrix[i][j] = yourMatrix(i, j) * re;
}
}
return result;
}
std::ostream& operator <<(std::ostream& os, const Matrix& yourMatrix)
{
for (int i = 0; i < yourMatrix.row; i++)
{
for (int j = 0; j < yourMatrix.col; j++)
{
os << yourMatrix(i, j) << " ";
}
os << endl;
}
return os;
};