-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovingAverage.cpp
More file actions
54 lines (47 loc) · 1.08 KB
/
Copy pathmovingAverage.cpp
File metadata and controls
54 lines (47 loc) · 1.08 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
#include "movingAverage.hpp"
movingAverage::movingAverage(long long int nMean,signal *x)
{
setNMean(nMean);
setX(x);
}
movingAverage::movingAverage(movingAverage &toCopy) noexcept : nMean{toCopy.getNMean()}, x{toCopy.getX()}
{
}
movingAverage& movingAverage::operator=(movingAverage &toCopy) noexcept
{
setNMean(toCopy.getNMean());
setX(x);
return *this;
}
movingAverage::movingAverage(movingAverage &&toMove) noexcept : nMean{std::move(toMove.getNMean())},x{std::move(toMove.getX())}
{
}
movingAverage& movingAverage::operator=(movingAverage &&toMove) noexcept
{
setNMean(std::move(toMove.getNMean()));
setX(std::move(toMove.getX()));
return *this;
}
std::complex<double> movingAverage::get(long long int n)
{
std::complex<double> average(0,0);
for(int k=n-getNMean() ; k <=n ; k++ )
average+=x->get(k);
return average/(double)getNMean();
}
long long int movingAverage::getNMean() const
{
return nMean;
}
void movingAverage::setNMean(long long int nMean)
{
this->nMean = nMean;
}
signal* movingAverage::getX()
{
return x;
}
void movingAverage::setX(signal *x)
{
this->x = x;
}