[med-svn] [aghermann] 17/31: obscure fixes in sigproc::interpolate, envelope
andrei zavada
hmmr-guest at alioth.debian.org
Sun Nov 10 00:34:17 UTC 2013
This is an automated email from the git hooks/post-receive script.
hmmr-guest pushed a commit to branch WIP
in repository aghermann.
commit 7ec89c74450a5683f05f6bd1be2ee8c0ac218ba8
Author: Andrei Zavada <hmmr at ra>
Date: Sat Nov 9 20:41:39 2013 +0200
obscure fixes in sigproc::interpolate, envelope
---
upstream/src/libsigproc/sigproc.hh | 1 +
upstream/src/libsigproc/sigproc.ii | 15 +++++++--------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/upstream/src/libsigproc/sigproc.hh b/upstream/src/libsigproc/sigproc.hh
index 837ee37..6765ecf 100644
--- a/upstream/src/libsigproc/sigproc.hh
+++ b/upstream/src/libsigproc/sigproc.hh
@@ -13,6 +13,7 @@
#define AGH_LIBSIGPROC_SIGPROC_H_
#include <cmath>
+#include <cstring>
#include <vector>
#include <valarray>
#include <stdexcept>
diff --git a/upstream/src/libsigproc/sigproc.ii b/upstream/src/libsigproc/sigproc.ii
index 7dab3d1..4d847f9 100644
--- a/upstream/src/libsigproc/sigproc.ii
+++ b/upstream/src/libsigproc/sigproc.ii
@@ -69,7 +69,7 @@ derivative( const valarray<T>& a)
template <typename T, class Container>
valarray<T>
-interpolate( const vector<unsigned long>& xi,
+interpolate( const vector<size_t>& xi,
unsigned samplerate, const Container& y, double dt)
{
size_t i;
@@ -87,11 +87,11 @@ interpolate( const vector<unsigned long>& xi,
gsl_spline_init( spline, &x_known[0], &y_known[0], xi.size());
double t;
- size_t pad = (1./samplerate / dt) // this I understand
- / 2; // this, I don't
+ auto xknown0 = x_known[0],
+ xknown9 = x_known[x_known.size()-1];
valarray<T>
- out (ceilf((x_known[x_known.size()-1] - x_known[0] + 1./samplerate) / dt) + 1);
- for ( i = pad, t = x_known[0]; t < x_known[x_known.size()-1]; ++i, t += dt )
+ out (ceilf((xknown9 - xknown0) / dt));
+ for ( i = 0, t = xknown0 + dt/2; i < out.size(); ++i, t += dt )
out[i] = gsl_spline_eval( spline, t, acc);
gsl_interp_accel_free( acc);
@@ -134,7 +134,6 @@ envelope( const SSignalRef<T>& in,
if ( S[i] == lmax && i != i-dh2 && i != i+dh2 ) {
maxi.push_back(i);
i += dh2 - 1;
- continue;
}
}
for ( i = dh2; i < n_samples-dh2; ++i ) {
@@ -146,8 +145,8 @@ envelope( const SSignalRef<T>& in,
}
// put a point at end
- mini.push_back( i);
- maxi.push_back( i);
+ mini.push_back( n_samples-1);
+ maxi.push_back( n_samples-1);
if ( mini.size() > 5 && maxi.size() > 5 ) {
if ( env_lp )
--
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git
More information about the debian-med-commit
mailing list