From d1d8668bd9e63ed1783252a152823797e6cd5047 Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm <philipp@uvos.xyz> Date: Tue, 6 Feb 2024 10:50:05 +0100 Subject: [PATCH] add trival difference function --- basicmath.cpp | 7 +++++++ eisgenerator/basicmath.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/basicmath.cpp b/basicmath.cpp index 1c46413..74cfcc9 100644 --- a/basicmath.cpp +++ b/basicmath.cpp @@ -411,3 +411,10 @@ std::vector<eis::DataPoint> eis::fitToFrequencies(std::vector<fvalue> omegas, co return out; } + +void difference(std::vector<eis::DataPoint>& a, const std::vector<eis::DataPoint>& b) +{ + assert(a.size() == b.size()); + for(size_t i = 0; i < a.size(); ++i) + a[i] = a[i] - b[i]; +} diff --git a/eisgenerator/basicmath.h b/eisgenerator/basicmath.h index d557180..4d9d7ff 100644 --- a/eisgenerator/basicmath.h +++ b/eisgenerator/basicmath.h @@ -89,6 +89,17 @@ namespace eis */ std::complex<fvalue> median(const std::vector<eis::DataPoint>& data); + + /** + * @brief Calculates the difference between two spectra. + * + * this function calculates an element wise a = a-b and ingores omega + * + * @param a The first operand, where b is subtracted + * @param b The second operand that is subtracted from the first, must be the same size as a + */ + void difference(std::vector<eis::DataPoint>& a, const std::vector<eis::DataPoint>& b); + /** * @brief Resamples the data to the given amount of points. * -- GitLab