commit cb86ca55d0532d0f6eb33a61a909d5813362abbf
parent cfe345829f43ac15c54805036264cca78829ccd8
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Wed, 7 Sep 2016 19:02:56 +0300
Add autocorrelate function
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/kfr/dft/conv.hpp b/include/kfr/dft/conv.hpp
@@ -78,5 +78,13 @@ KFR_INTRIN univector<T> correlate(const univector<T, Tag1>& src1, const univecto
const T invsize = reciprocal<T>(size);
return truncate(real(src1padded), src1.size() + src2.size() - 1) * invsize;
}
+
+template <typename T, size_t Tag1>
+KFR_INTRIN univector<T> autocorrelate(const univector<T, Tag1>& src)
+{
+ univector<T> result = correlate(src, src);
+ result = result.slice(result.size() / 2);
+ return result;
+}
}
#pragma clang diagnostic pop