Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
Seitosh
Commits
9a45ed6c
Commit
9a45ed6c
authored
Jan 14, 2019
by
thomas.forbriger
Browse files
libpsdxx [WP][FIX]: make LogTaper produce correct values
parent
0ab36294
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/libpsdxx/log_taper.cc
View file @
9a45ed6c
...
...
@@ -35,6 +35,7 @@
#include <psdxx/helper.h>
#include <psdxx/error.h>
#include <psdxx/debug.h>
#include <cmath>
namespace
psd
{
...
...
@@ -46,21 +47,22 @@ namespace psd {
{
PSDXX_assert
(
f
.
size
()
>
2
,
"at least three values of frequency are required"
);
if
(
i
==
0
)
PSDXX_assert
((
i
>=
f
.
f
())
&&
(
i
<=
f
.
l
()),
"index is out of range"
);
if
(
i
==
f
.
f
())
{
this
->
Mloc
=
Flower_end
;
this
->
Mli
=
new
psd
::
helper
::
LogIndex
(
f
(
f
.
f
()),
f
(
f
.
f
()
+
1
),
f
(
f
.
f
()
+
2
));
this
->
Mli
=
new
psd
::
helper
::
LogIndex
(
f
(
i
),
f
(
i
+
1
),
f
(
i
+
2
));
}
else
if
(
i
==
(
f
.
size
()
-
1
))
else
if
(
i
==
f
.
l
(
))
{
this
->
Mloc
=
Fupper_end
;
this
->
Mli
=
new
psd
::
helper
::
LogIndex
(
f
(
f
.
l
()
-
2
),
f
(
f
.
l
()
-
1
),
f
(
f
.
l
()
));
this
->
Mli
=
new
psd
::
helper
::
LogIndex
(
f
(
i
-
2
),
f
(
i
-
1
),
f
(
i
));
}
else
{
this
->
Mloc
=
Fmiddle
;
this
->
Mli
=
new
psd
::
helper
::
LogIndex
(
f
(
f
.
f
()
+
i
-
1
),
f
(
f
.
f
()
+
i
),
f
(
f
.
f
()
+
i
+
1
));
this
->
Mli
=
new
psd
::
helper
::
LogIndex
(
f
(
i
-
1
),
f
(
i
),
f
(
i
+
1
));
}
}
// LogTaper::LogTaper(const psd::TDseries::Tcoc& f,
// const unsigned int& i)
...
...
@@ -89,7 +91,7 @@ namespace psd {
// taper is 1 for frequency index <= 0
if
((
rindex
>
0.
)
&&
(
rindex
<
1.
))
{
retval
=
0.5
*
(
1.
-
std
::
sin
(
rindex
*
M_PI
));
retval
=
0.5
*
(
1.
+
std
::
cos
(
rindex
*
M_PI
));
}
else
if
(
rindex
<=
0.
)
{
...
...
@@ -101,9 +103,14 @@ namespace psd {
// index of center frequency is 2
// index range is from +1 to +3
// taper is 1 for frequency index >= 2
if
((
rindex
<
2
.
)
&&
(
rindex
>
1
.
))
if
((
rindex
>=
1
.
)
&&
(
rindex
<
2
.
))
{
retval
=
0.5
*
(
1.
-
std
::
sin
(
rindex
*
M_PI
));
retval
=
0.5
*
(
1.
+
std
::
cos
(
rindex
*
M_PI
));
/*
std::cerr << PSDXX_value(f) << " "
<< PSDXX_value(rindex) << " "
<< PSDXX_value(retval) << std::endl;
*/
}
else
if
(
rindex
>=
2.
)
{
...
...
@@ -114,7 +121,7 @@ namespace psd {
{
// index of center frequency is 1
// index range is from 0 to +2
if
((
rindex
>
-
2
.
)
&&
(
rindex
<
2.
))
if
((
rindex
>
-
0
.
)
&&
(
rindex
<
2.
))
{
retval
=
0.5
*
(
1.
-
std
::
cos
(
rindex
*
M_PI
));
}
...
...
src/libs/libpsdxx/testlogtaper.gpt
View file @
9a45ed6c
...
...
@@ -20,7 +20,10 @@ set output 'logtaper.ps'
set logscale x
unset logscale y
set mxtics 10
set grid
set mytics 5
set grid xtics,ytics
set grid mxtics,mytics
set key left
set title 'LogTaper'
set xlabel 'frequency / Hz'
set ylabel 'taper value'
...
...
src/libs/libpsdxx/testpsdxx.cc
View file @
9a45ed6c
...
...
@@ -153,9 +153,9 @@ int main(int iargc, char* argv[])
if
(
opt
.
logtaper
)
{
const
int
nsamples
=
3
00
;
const
int
nsamples
=
1
00
;
cout
<<
"test class LogTaper"
<<
endl
;
CODE
(
psd
::
TDseries
linf
=
psd
::
lin_frequency
(
0.1
,
nsamples
)
);
CODE
(
psd
::
TDseries
linf
=
psd
::
lin_frequency
(
0.
0
1
,
nsamples
*
10
)
);
CODE
(
psd
::
TDseries
logf
=
psd
::
log_frequency
(
0.1
,
nsamples
,
6
)
);
CODE
(
psd
::
helper
::
LogTaper
logt
(
logf
,
opt
.
taperindex
)
);
DUMP
(
logf
);
...
...
Write
Preview
Markdown
is supported
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