eisgenerator 2.1.x
basicmath.h
1//SPDX-License-Identifier: LGPL-3.0-or-later
2/* * eisgenerator - a shared library and application to generate EIS spectra
3 * Copyright (C) 2022-2024 Carl Philipp Klemm <carl@uvos.xyz>
4 *
5 * This file is part of eisgenerator.
6 *
7 * eisgenerator is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * eisgenerator is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with eisgenerator. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22#include <vector>
23#include <kisstype/type.h>
24
25namespace eis
26{
32
33 void mulitplyAdd(std::vector<eis::DataPoint>& data, fvalue mult, fvalue add);
34
42 std::complex<fvalue> absGrad(const std::vector<eis::DataPoint>& data, size_t index);
43
51 fvalue grad(const std::vector<fvalue>& data, const std::vector<fvalue>& omega, size_t index);
52
60 std::complex<fvalue> grad(const std::vector<eis::DataPoint>& data, size_t index);
61
68 fvalue mean(const std::vector<fvalue>& data);
69
76 std::complex<fvalue> mean(const std::vector<eis::DataPoint>& data);
77
84 fvalue median(std::vector<fvalue> data);
85
92 std::complex<fvalue> median(const std::vector<eis::DataPoint>& data);
93
94
103 void difference(std::vector<eis::DataPoint>& a, const std::vector<eis::DataPoint>& b);
104
112 std::vector<eis::DataPoint> rescale(const std::vector<eis::DataPoint>& data, size_t outputSize);
113
120 fvalue pearsonCorrelation(const std::vector<eis::DataPoint>& data);
121
122 fvalue nonConstantScore(const std::vector<eis::DataPoint>& data);
123
131 fvalue nyquistAreaVariance(const std::vector<eis::DataPoint>& data, eis::DataPoint* centroid = nullptr);
132
139 fvalue maximumNyquistJump(const std::vector<eis::DataPoint>& data);
140
148 void noise(std::vector<eis::DataPoint>& data, double amplitude, bool relative);
149
157 void removeDuplicates(std::vector<eis::DataPoint>& data);
158
168 bool fvalueEq(fvalue a, fvalue b, unsigned int ulp = 4);
169
181 std::vector<eis::DataPoint> fitToFrequencies(std::vector<fvalue> omegas,
182 const std::vector<eis::DataPoint>& data,
183 bool linearExtrapolation = false);
184
194 fvalue eisDistance(const std::vector<eis::DataPoint>& a, const std::vector<eis::DataPoint>& b);
195
196
208 fvalue eisNyquistDistance(const std::vector<eis::DataPoint>& a, const std::vector<eis::DataPoint>& b);
209
211}
212
213
std::vector< eis::DataPoint > fitToFrequencies(std::vector< fvalue > omegas, const std::vector< eis::DataPoint > &data, bool linearExtrapolation=false)
This function resamples, extrapolates and interpolates to fit the data given to the frequencies also ...
std::vector< eis::DataPoint > rescale(const std::vector< eis::DataPoint > &data, size_t outputSize)
Resamples the data to the given amount of points.
fvalue median(std::vector< fvalue > data)
Calculates the median of the given data.
fvalue mean(const std::vector< fvalue > &data)
Calculates the mean of the given data.
void difference(std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
Calculates the difference between two spectra.
fvalue maximumNyquistJump(const std::vector< eis::DataPoint > &data)
Finds the maximum distance between subsequent points in the data in the nyquist plane.
fvalue nyquistAreaVariance(const std::vector< eis::DataPoint > &data, eis::DataPoint *centroid=nullptr)
Calculates the variance of the distance of the data from a centroid in the nyquist plane.
void removeDuplicates(std::vector< eis::DataPoint > &data)
Removes duplicate data points from the data.
fvalue eisDistance(const std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
Returns the mean l2 element wise distance of the given spectra.
fvalue grad(const std::vector< fvalue > &data, const std::vector< fvalue > &omega, size_t index)
Calculates derivative at the given point of the data given.
bool fvalueEq(fvalue a, fvalue b, unsigned int ulp=4)
Checks two fvalues for equality.
void noise(std::vector< eis::DataPoint > &data, double amplitude, bool relative)
Adds white noise to the data.
fvalue pearsonCorrelation(const std::vector< eis::DataPoint > &data)
Calculates the Pearson correlation between the imaginary and the real part of the data.
fvalue eisNyquistDistance(const std::vector< eis::DataPoint > &a, const std::vector< eis::DataPoint > &b)
Returns the mean distance of the points in a to the linearly interpolated nyquist curve of b.
std::complex< fvalue > absGrad(const std::vector< eis::DataPoint > &data, size_t index)
Calculates the element wise absolute gradient at the given point of the data given.
eisgenerator Copyright (C) 2021 Carl Klemm
Definition basicmath.h:26