Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
Seitosh
Commits
80c36038
Commit
80c36038
authored
Jan 21, 2019
by
thomas.forbriger
Browse files
libpsdxx [WP][DOC]: add todo note regarding code efficiency
parent
084e7800
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/libs/libpsdxx/function_template_log_sampling.h
View file @
80c36038
...
...
@@ -38,9 +38,58 @@
"PSDXX_FUNCTION_TEMPLATE_LOG_SAMPLING_H V1.0"
#include
<psdxx/psd.h>
#include
<psdxx/helper.h>
namespace
psd
{
namespace
helper
{
/*! generic template function
*
* \param s spectral values with uniform sampling along frequency axis
* \param f frequency values on a logarithmic scale like returned by
* function log_frequency()
* \return series of sampled spectral values, where each sample of the
* returned series corresponds to the frequency with the
* corresponding index in \p f
*/
template
<
typename
T
>
aff
::
Series
<
T
>
gen_log_sampling
(
const
typename
psd
::
IntervalSeries
<
T
>::
Tcoc
&
s
,
const
TDseries
::
Tcoc
&
f
)
{
aff
::
Series
<
T
>
retval
(
f
.
f
(),
f
.
l
());
retval
=
T
(
0.
);
for
(
int
i
=
f
.
f
();
i
<=
f
.
l
();
++
i
)
{
psd
::
helper
::
LogTaper
logtaper
(
f
,
i
);
/*! \todo
* Sample spectral values and computed weighted average. logtaper
* will return zero for most values and the computation of these
* zeroes is quite expensive. There would be a more efficient way to
* do the computation by limiting the sampling to the a-priori known
* frequency interval of non-zero taper values.
* This is left to future improvements of the code.
* See also comment in
* double LogTaper::operator()(const double& f)
* \sa psd::helper::LogTaper::operator())()
*/
for
(
int
j
=
s
.
data
.
f
();
j
<=
s
.
data
.
l
();
++
j
)
{
double
freq
=
s
.
interval
*
(
j
-
s
.
data
.
f
());
double
taper
=
logtaper
(
freq
);
retval
(
i
)
+=
taper
*
s
.
data
(
j
);
}
retval
(
i
)
/=
logtaper
.
sum
();
}
// for (int i=f.f(); i<=f.l(); ++i)
return
(
retval
);
}
// template<typename T>
// aff::Series<T>
// gen_log_sampling(const typename psd::IntervalSeries<T>::Tcoc& s,
// const TDseries::Tcoc& f)
}
// namespace helper
}
// namespace psd
#endif // PSDXX_FUNCTION_TEMPLATE_LOG_SAMPLING_H_VERSION (includeguard)
...
...
src/libs/libpsdxx/log_taper.cc
View file @
80c36038
...
...
@@ -79,6 +79,15 @@ namespace psd {
double
LogTaper
::
operator
()(
const
double
&
f
)
{
double
retval
=
0
;
/*! \todo
* there would be a more efficient way to find the interval of non-zero
* taper values. This would require to store the boundary values of this
* interval in the constructor. Calling the index function for every
* frequency to find the position in the sequence, is computationally
* very expensive and only necessary for values where taper values or to
* be finite.
* This is left to future improvements of the code.
*/
double
rindex
=
this
->
Mli
->
operator
()(
f
);
// taper function
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment