Main Page
Classes
Files
File List
File Members
kogmo_fob
trackerServer
kogmo_fob/trackerServer/complex.h
Go to the documentation of this file.
1
18
#ifndef __COMPLEX_H
19
#define __COMPLEX_H
20
21
#include <cmath>
22
#include <cstdio>
23
24
double
epsilon
= 0.0000001;
25
26
struct
complex
{
double
r
;
double
i
;};
27
28
complex
czero
= {0,0};
29
30
complex
cmul
(
complex
a,
complex
b)
31
{
32
complex
r
;
33
r.
r
=a.
r
*b.
r
-a.
i
*b.
i
;
34
r.
i
=a.
i
*b.
r
+a.
r
*b.
i
;
35
return
r
;
36
}
37
38
complex
cadd
(
complex
a,
complex
b)
39
{
40
complex
r
;
41
r.
r
=a.
r
+b.
r
;
42
r.
i
=a.
i
+b.
i
;
43
return
r
;
44
}
45
46
complex
csub
(
complex
a,
complex
b)
47
{
48
complex
r
;
49
r.
r
=a.
r
-b.
r
;
50
r.
i
=a.
i
-b.
i
;
51
return
r
;
52
}
53
54
complex
r2c
(
double
x)
55
{
56
complex
r
;
57
r.
r
=x;
58
r.
i
=0;
59
return
r
;
60
}
61
62
bool
isEqual
(
complex
a,
complex
b)
63
{
64
return
((a.
r
==b.
r
)&&(a.
i
==b.
i
));
65
}
66
67
bool
isEqualE
(
complex
a,
complex
b)
68
{
69
return
((
abs
(a.
r
-b.
r
)<
epsilon
)&&(
abs
(a.
i
-b.
i
)<
epsilon
));
70
}
71
72
complex
cpow
(
complex
a,
int
b)
73
{
74
complex
r
;
75
r=a;
76
for
(
int
i
=1;
i
<b;
i
++) r=
cmul
(r,a);
77
return
r
;
78
}
79
80
complex
cdiv
(
complex
a,
complex
b)
81
{
82
complex
r
;
83
double
B=b.
r
*b.
r
+b.
i
*b.
i
;
84
r.
r
=(a.
r
*b.
r
+a.
i
*b.
i
)/B;
85
r.
i
=(a.
i
*b.
r
-a.
r
*b.
i
)/B;
86
return
r
;
87
}
88
89
complex
cexp
(
complex
a){
90
complex
r
;
91
double
length
,
angle
;
92
length=exp(a.
r
);
93
angle=a.
i
;
94
r.
r
=cos(angle)*length;
95
r.
i
=sin(angle)*length;
96
return
r
;
97
}
98
99
complex
cln
(
complex
a){
100
complex
r
;
101
double
length
,
angle
;
102
length=sqrt(a.
r
*a.
r
+a.
i
*a.
i
);
103
angle=atan2(a.
i
,a.
r
);
104
r.
r
=log(length);
105
r.
i
=angle;
106
return
r
;
107
}
108
109
complex
cneg
(
complex
a){
110
complex
r
;
111
r.
r
=-a.
r
;
112
r.
i
=-a.
i
;
113
return
r
;
114
}
115
116
complex
cpos
(
complex
a){
117
return
a;
118
}
119
120
complex
csqrt
(
complex
a)
121
{
122
complex
r
;
123
double
length
,
angle
;
124
length=sqrt(sqrt(a.
r
*a.
r
+a.
i
*a.
i
));
125
angle=atan2(a.
i
,a.
r
)/2;
126
r.
r
=cos(angle)*length;
127
r.
i
=sin(angle)*length;
128
return
r
;
129
}
130
131
void
cprint
(
complex
c)
132
{
133
printf(
"%f"
,c.
r
);
134
if
(c.
i
>0) printf(
"+%fi"
,c.
i
);
135
if
(c.
i
<0) printf(
"%fi"
,c.
i
);
136
printf(
"\n"
);
137
}
138
139
bool
isReal
(
complex
x)
140
{
141
return
(
abs
(x.
i
)<=
epsilon
);
142
}
143
#endif
cprint
void cprint(complex c)
Definition:
kogmo_fob/trackerServer/complex.h:131
cadd
complex cadd(complex a, complex b)
Definition:
kogmo_fob/trackerServer/complex.h:38
csqrt
complex csqrt(complex a)
Definition:
kogmo_fob/trackerServer/complex.h:120
cexp
complex cexp(complex a)
Definition:
kogmo_fob/trackerServer/complex.h:89
complex::r
double r
Definition:
include/complex.h:26
csub
complex csub(complex a, complex b)
Definition:
kogmo_fob/trackerServer/complex.h:46
cpow
complex cpow(complex a, int b)
Definition:
kogmo_fob/trackerServer/complex.h:72
isEqual
bool isEqual(complex a, complex b)
Definition:
kogmo_fob/trackerServer/complex.h:62
epsilon
double epsilon
Definition:
kogmo_fob/trackerServer/complex.h:24
angle
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
cln
complex cln(complex a)
Definition:
kogmo_fob/trackerServer/complex.h:99
cneg
complex cneg(complex a)
Definition:
kogmo_fob/trackerServer/complex.h:109
r2c
complex r2c(double x)
Definition:
kogmo_fob/trackerServer/complex.h:54
cpos
complex cpos(complex a)
Definition:
kogmo_fob/trackerServer/complex.h:116
isReal
bool isReal(complex x)
Definition:
kogmo_fob/trackerServer/complex.h:139
length
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
cmul
complex cmul(complex a, complex b)
Definition:
kogmo_fob/trackerServer/complex.h:30
complex
Definition:
include/complex.h:26
isEqualE
bool isEqualE(complex a, complex b)
Definition:
kogmo_fob/trackerServer/complex.h:67
complex::i
double i
Definition:
include/complex.h:26
abs
double abs(quaternion a)
Definition:
include/quaternion.h:99
czero
complex czero
Definition:
kogmo_fob/trackerServer/complex.h:28
cdiv
complex cdiv(complex a, complex b)
Definition:
kogmo_fob/trackerServer/complex.h:80
asr_flock_of_birds
Author(s): Bernhardt Andre, Engelmann Stephan, Giesler Björn, Heller Florian, Jäkel Rainer, Nguyen Trung, Pardowitz Michael, Weckesser Peter, Yi Xie, Zöllner Raoul
autogenerated on Mon Jun 10 2019 12:44:40