diff --git a/basicmath.cpp b/basicmath.cpp index 1c4641312abc32c6d6a5e217b1b1244898d17c18..74cfcc97d236ed075d18d054737f55e270a5e7ff 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 d5571800d93782e3f60e0a547584acc123da911a..4d9d7ffa2c9c596e401d0a698f837407f4e181d2 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. *