Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
4508ebd5
Commit
4508ebd5
authored
Feb 24, 2008
by
Jean-Marc Valin
Browse files
real fft snr comparison testcase includes DC
parent
44830b04
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/real-fft-test.c
View file @
4508ebd5
...
...
@@ -26,12 +26,15 @@ double snr_compare( kiss_fft_cpx * vec1,kiss_fft_scalar * vec2, int n)
int
k
;
double
sigpow
=
1e-10
,
noisepow
=
1e-10
,
err
,
snr
;
for
(
k
=
1
;
k
<
n
;
++
k
)
{
vec1
[
0
].
i
=
vec1
[
n
].
r
;
for
(
k
=
0
;
k
<
n
;
++
k
)
{
sigpow
+=
(
double
)
vec1
[
k
].
r
*
(
double
)
vec1
[
k
].
r
+
(
double
)
vec1
[
k
].
i
*
(
double
)
vec1
[
k
].
i
;
err
=
(
double
)
vec1
[
k
].
r
-
(
double
)
vec2
[
2
*
k
];
/*printf ("%f %f\n", (double)vec1[k].r, (double)vec2[2*k]);*/
noisepow
+=
err
*
err
;
err
=
(
double
)
vec1
[
k
].
i
-
(
double
)
vec2
[
2
*
k
+
1
];
/*printf ("%f %f\n", (double)vec1[k].i, (double)vec2[2*k+1]);*/
noisepow
+=
err
*
err
;
}
...
...
@@ -49,7 +52,7 @@ double snr_compare_scal( kiss_fft_scalar * vec1,kiss_fft_scalar * vec2, int n)
int
k
;
double
sigpow
=
1e-10
,
noisepow
=
1e-10
,
err
,
snr
;
for
(
k
=
1
;
k
<
n
;
++
k
)
{
for
(
k
=
0
;
k
<
n
;
++
k
)
{
sigpow
+=
(
double
)
vec1
[
k
]
*
(
double
)
vec1
[
k
];
err
=
(
double
)
vec1
[
k
]
-
(
double
)
vec2
[
k
];
noisepow
+=
err
*
err
;
...
...
@@ -83,8 +86,6 @@ int main(void)
kiss_fft_scalar
zero
;
memset
(
&
zero
,
0
,
sizeof
(
zero
)
);
// ugly way of setting short,int,float,double, or __m128 to zero
srand
(
time
(
0
));
for
(
i
=
0
;
i
<
NFFT
;
++
i
)
{
rin
[
i
]
=
rand_scalar
();
cin
[
i
].
r
=
rin
[
i
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment