CuteLogger
Fast and simple logging solution for Qt based applications
alignmentarray.h
1 /*
2  * Copyright (c) 2022 Meltytech, LLC
3  *
4  * Author: AndrĂ© Caldas de Souza <andrecaldas@unb.br>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ALIGNMENTARRAY_H
21 #define ALIGNMENTARRAY_H
22 
23 #include <QMutex>
24 
25 #include <complex.h>
26 #include <fftw3.h>
27 #include <vector>
28 
29 class AlignmentArray
30 {
31 public:
32  AlignmentArray();
33  AlignmentArray(size_t minimum_size);
34  virtual ~AlignmentArray();
35 
36  void init(size_t minimum_size);
37  void setValues(const std::vector<double> &values);
38  double calculateOffset(AlignmentArray &from, int *offset);
39  double calculateOffsetAndSpeed(AlignmentArray &from, double *speed, int *offset, double speedRange);
40 
41 private:
42  void transform();
43  std::vector<double> m_values;
44  fftw_plan m_forwardPlan;
45  std::complex<double> *m_forwardBuf;
46  fftw_plan m_backwardPlan;
47  std::complex<double> *m_backwardBuf;
48  double m_autocorrelationMax;
49  size_t m_minimumSize;
50  size_t m_actualComplexSize;
51  bool m_isTransformed;
52  QMutex m_transformMutex;
53 };
54 
55 #endif
56