Xmipp  v3.23.11-Nereus
shift_corr_estimator.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: David Strelak (davidstrelak@gmail.com)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef LIBRARIES_RECONSTRUCTION_SHIFT_CORR_ESTIMATOR_H_
27 #define LIBRARIES_RECONSTRUCTION_SHIFT_CORR_ESTIMATOR_H_
28 
29 #include <typeinfo>
30 
31 #include "data/fftwT.h"
32 #include "ashift_corr_estimator.h"
33 #include "data/cpu.h"
34 #include "single_extrema_finder.h"
35 
39 namespace Alignment {
40 
41 template<typename T>
43 public:
45  setDefault();
46  }
47 
48  virtual ~ShiftCorrEstimator() {
49  release();
50  }
51 
52  void release() override;
53 
54  void init2D(const std::vector<HW*> &hw, AlignType type, const FFTSettings<T> &dims, size_t maxShift,
55  bool includingBatchFT, bool includingSingleFT,
56  bool allowDataOverwrite) override;
57 
58  void load2DReferenceOneToN(const std::complex<T> *ref) override;
59 
60  void load2DReferenceOneToN(const T *ref) override;
61 
62  void computeShift2DOneToN(T *others) override;
63 
64  static std::vector<Point2D<float>> computeShifts2DOneToN(
65  const CPU &cpu,
66  std::complex<T> *othersF,
67  T *othersS,
68  std::complex<T> *ref,
69  const FFTSettings<T> &settings,
70  void *plan,
71  size_t maxShift);
72 
73  void computeCorrelations2DOneToN(std::complex<T> *inOut, bool center) override;
74 
76  const HW &hw,
77  std::complex<T> *inOut,
78  const std::complex<T> *ref,
79  const Dimensions &dims,
80  bool center) override;
81 
82  static inline void sComputeCorrelations2DOneToN(
83  const HW &hw,
84  std::complex<T> *inOut,
85  const std::complex<T> *ref,
86  const Dimensions &dims,
87  bool center) {
88  if (center) {
89  sComputeCorrelations2DOneToN<true>(hw, inOut, ref, dims);
90  } else {
91  sComputeCorrelations2DOneToN<false>(hw, inOut, ref, dims);
92  }
93  }
94 
95  template<bool CENTER>
96  static void sComputeCorrelations2DOneToN(
97  const HW &hw,
98  std::complex<T> *inOut,
99  const std::complex<T> *ref,
100  const Dimensions &dims);
101 
102  HW& getHW() const override {
103  return *m_cpu;
104  }
105 private:
106  CPU *m_cpu;
107 
108  // host memory
109  std::complex<T> *m_single_FD;
110  std::complex<T> *m_batch_FD;
111  T * m_batch_SD;
112 
113  // FT plans
114  void *m_singleToFD;
115  void *m_batchToFD;
116  void *m_batchToSD;
117 
118  void init2DOneToN() override;
119  void check() override;
120  void setDefault() override;
121 };
122 
123 } /* namespace Alignment */
125 #endif /* LIBRARIES_RECONSTRUCTION_SHIFT_CORR_ESTIMATOR_H_ */
void load2DReferenceOneToN(const std::complex< T > *ref) override
Definition: hw.h:35
void init2D(const std::vector< HW *> &hw, AlignType type, const FFTSettings< T > &dims, size_t maxShift, bool includingBatchFT, bool includingSingleFT, bool allowDataOverwrite) override
viol type
void computeCorrelations2DOneToN(std::complex< T > *inOut, bool center) override
static std::vector< Point2D< float > > computeShifts2DOneToN(const CPU &cpu, std::complex< T > *othersF, T *othersS, std::complex< T > *ref, const FFTSettings< T > &settings, void *plan, size_t maxShift)
Definition: cpu.h:37
void computeShift2DOneToN(T *others) override
static void sComputeCorrelations2DOneToN(const HW &hw, std::complex< T > *inOut, const std::complex< T > *ref, const Dimensions &dims, bool center)