forked from DavidEilenstein/PolarisationSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathps_mat.cpp
More file actions
66 lines (57 loc) · 1.43 KB
/
ps_mat.cpp
File metadata and controls
66 lines (57 loc) · 1.43 KB
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
#include "ps_mat.h"
PS_Mat::PS_Mat()
{
data[0][0] = 1;
data[0][1] = 0;
data[1][0] = 0;
data[1][1] = 1;
}
PS_Mat::PS_Mat(double angle)
{
angle *= Grad2Rad;
data[0][0] = cos(angle);
data[0][1] = -sin(angle);
data[1][0] = sin(angle);
data[1][1] = cos(angle);
//Info();
}
PS_Mat::PS_Mat(complex<double> x11, complex<double> x12, complex<double> x21, complex<double> x22)
{
data[0][0] = x11;
data[0][1] = x12;
data[1][0] = x21;
data[1][1] = x22;
}
void PS_Mat::Info()
{
cout << "matrix:" << endl;
cout << data[0][0] << data[0][1] << endl;
cout << data[1][0] << data[1][1] << endl;
cout << endl;
}
PS_Vec PS_Mat::operator*(PS_Vec V)
{
// R = A(this) * V
//
// V.x1
// V.x2
//
//A.x11 A.x12 R.x1
//A.x21 A.x22 R.x2
return PS_Vec(
x11() * V.x1() + x12() * V.x2(),
x21() * V.x1() + x22() * V.x2());
}
PS_Mat PS_Mat::operator*(PS_Mat M)
{
// R = A(this) * B
//
// B.x11 B.x12
// B.x21 B.x22
//
//A.x11 A.x12 R.x11 R.x21
//A.x21 A.x22 R.x21 R.x22
return PS_Mat(
x11() * M.x11() + x12() * M.x21(), x11() * M.x12() + x12() * M.x22(),
x21() * M.x11() + x22() * M.x21(), x21() * M.x12() + x22() * M.x22());
}