Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ettore Pane
Skyward Boardcore
Commits
99c94678
Commit
99c94678
authored
1 year ago
by
Federico Lolli
Browse files
Options
Downloads
Patches
Plain Diff
[FFT] improved fftfreq
parent
386db12f
Branches
vcm
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/shared/algorithms/FFT.h
+6
-4
6 additions, 4 deletions
src/shared/algorithms/FFT.h
src/tests/algorithms/FFT/test-fft-data.h
+6
-6
6 additions, 6 deletions
src/tests/algorithms/FFT/test-fft-data.h
src/tests/algorithms/FFT/test-fft.cpp
+1
-1
1 addition, 1 deletion
src/tests/algorithms/FFT/test-fft.cpp
with
13 additions
and
11 deletions
src/shared/algorithms/FFT.h
+
6
−
4
View file @
99c94678
...
...
@@ -40,7 +40,6 @@ template <int N_size>
class
FFT
{
public:
using
VectorHF
=
Eigen
::
Vector
<
float
,
N_size
/
2
>
;
using
VectorF
=
Eigen
::
Vector
<
float
,
N_size
>
;
using
VectorCF
=
Eigen
::
Vector
<
std
::
complex
<
float
>
,
N_size
>
;
...
...
@@ -90,18 +89,21 @@ public:
/**
* @brief Get the frequency used in the FFT
* (only the first half, useful for real input functions)
*
* @param sample_rate in Hertz
* @return Eigen::Vector<std::complex<float>, N_size>
*/
static
const
Vector
H
F
fftfreq
(
float
sample_rate
)
static
const
VectorF
fftfreq
(
float
sample_rate
)
{
Vector
H
F
bins
=
Vector
H
F
::
Zero
();
VectorF
bins
=
VectorF
::
Zero
();
for
(
int
i
=
0
;
i
<
N_size
/
2
;
i
++
)
{
bins
(
i
)
=
(
float
)
i
*
sample_rate
/
(
float
)
N_size
;
}
for
(
int
i
=
N_size
/
2
;
i
<
N_size
;
i
++
)
{
bins
(
i
)
=
(
float
)(
i
-
N_size
)
*
sample_rate
/
(
float
)
N_size
;
}
return
bins
;
}
...
...
This diff is collapsed.
Click to expand it.
src/tests/algorithms/FFT/test-fft-data.h
+
6
−
6
View file @
99c94678
...
...
@@ -57,9 +57,9 @@ static const std::vector<float> INTENSITY{
static
const
std
::
vector
<
float
>
FREQUENCY
{
0.0
,
1.0
,
2.0
,
3.0
,
4.0
,
5.0
,
6.0
,
7.0
,
8.0
,
9.0
,
10.0
,
11.0
,
12.0
,
13.0
,
14.0
,
15.0
,
16.0
,
17.0
,
18.0
,
19.0
,
20.0
,
21.0
,
22.0
,
23.0
,
24.0
,
25.0
,
26.0
,
27.0
,
28.0
,
29.0
,
30.0
,
31.0
,
32.0
,
31.0
,
32
.0
,
33
.0
,
34
.0
,
35
.0
,
3
6.0
,
37
.0
,
38
.0
,
3
9
.0
,
40
.0
,
4
1.0
,
42.0
,
43
.0
,
44
.0
,
45
.0
,
46.0
,
4
7.0
,
48
.0
,
47
.0
,
4
8
.0
,
49
.0
,
50
.0
,
5
1.0
,
52
.0
,
53
.0
,
54
.0
,
55
.0
,
5
6.0
,
5
7
.0
,
58.0
,
59.0
,
60
.0
,
61
.0
,
6
2.0
,
63
.0
};
24.0
,
25.0
,
26.0
,
27.0
,
28.0
,
29.0
,
30.0
,
31.0
,
-
32.0
,
-
31.0
,
-
30
.0
,
-
29
.0
,
-
28
.0
,
-
27
.0
,
-
2
6.0
,
-
25
.0
,
-
24
.0
,
-
2
3.0
,
-
22
.0
,
-
2
1.0
,
-
20
.0
,
-
19
.0
,
-
18
.0
,
-
1
7.0
,
-
16
.0
,
-
15
.0
,
-
1
4.0
,
-
13
.0
,
-
12
.0
,
-
1
1.0
,
-
10
.0
,
-
9
.0
,
-
8
.0
,
-
7
.0
,
-
6.0
,
-
5.0
,
-
4
.0
,
-
3
.0
,
-
2.0
,
-
1
.0
};
}
// namespace Boardcore
This diff is collapsed.
Click to expand it.
src/tests/algorithms/FFT/test-fft.cpp
+
1
−
1
View file @
99c94678
...
...
@@ -44,7 +44,7 @@ int main()
Vector
<
std
::
complex
<
float
>
,
SAMPLES
>
fft_result
=
FFT
<
SAMPLES
>::
fft
(
signal_vector
);
Vector
<
float
,
SAMPLES
/
2
>
fft_freq
=
FFT
<
SAMPLES
>::
fftfreq
(
SAMPLE_RATE
);
Vector
<
float
,
SAMPLES
>
fft_freq
=
FFT
<
SAMPLES
>::
fftfreq
(
SAMPLE_RATE
);
for
(
int
i
=
0
;
i
<
fft_result
.
size
()
/
2
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment