Commit 80c36038 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libpsdxx [WP][DOC]: add todo note regarding code efficiency

parent 084e7800
...@@ -38,9 +38,58 @@ ...@@ -38,9 +38,58 @@
"PSDXX_FUNCTION_TEMPLATE_LOG_SAMPLING_H V1.0" "PSDXX_FUNCTION_TEMPLATE_LOG_SAMPLING_H V1.0"
#include <psdxx/psd.h> #include <psdxx/psd.h>
#include <psdxx/helper.h>
namespace psd { 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 } // namespace psd
#endif // PSDXX_FUNCTION_TEMPLATE_LOG_SAMPLING_H_VERSION (includeguard) #endif // PSDXX_FUNCTION_TEMPLATE_LOG_SAMPLING_H_VERSION (includeguard)
......
...@@ -79,6 +79,15 @@ namespace psd { ...@@ -79,6 +79,15 @@ namespace psd {
double LogTaper::operator()(const double& f) double LogTaper::operator()(const double& f)
{ {
double retval=0; 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); double rindex=this->Mli->operator()(f);
// taper function // taper function
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment