eisgenerator 1.0.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 "eistype.h"
24
25namespace eis
26{
40 std::complex<fvalue> absGrad(const std::vector<eis::DataPoint>& data, size_t index);
41
49 fvalue grad(const std::vector<fvalue>& data, const std::vector<fvalue>& omega, size_t index);
50
58 std::complex<fvalue> grad(const std::vector<eis::DataPoint>& data, size_t index);
59
66 fvalue mean(const std::vector<fvalue>& data);
67
74 std::complex<fvalue> mean(const std::vector<eis::DataPoint>& data);
75
82 fvalue median(std::vector<fvalue> data);
83
90 std::complex<fvalue> median(const std::vector<eis::DataPoint>& data);
91
92
101 void difference(std::vector<eis::DataPoint>& a, const std::vector<eis::DataPoint>& b);
102
110 std::vector<eis::DataPoint> rescale(const std::vector<eis::DataPoint>& data, size_t outputSize);
111
118 fvalue pearsonCorrelation(const std::vector<eis::DataPoint>& data);
119
127 fvalue nyquistAreaVariance(const std::vector<eis::DataPoint>& data, eis::DataPoint* centroid = nullptr);
128
135 fvalue maximumNyquistJump(const std::vector<eis::DataPoint>& data);
136
144 void noise(std::vector<eis::DataPoint>& data, double amplitude, bool relative);
145
153 void removeDuplicates(std::vector<eis::DataPoint>& data);
154
164 bool fvalueEq(fvalue a, fvalue b, unsigned int ulp = 4);
165
177 std::vector<eis::DataPoint> fitToFrequencies(std::vector<fvalue> omegas,
178 const std::vector<eis::DataPoint>& data,
179 bool linearExtrapolation = false);
180
182}
183
184
Basic singular EIS data point.
Definition eistype.h:47
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 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.
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