Xmipp  v3.23.11-Nereus
single_extrema_finder.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_SINGLE_EXTREMA_FINDER_H_
27 #define LIBRARIES_RECONSTRUCTION_SINGLE_EXTREMA_FINDER_H_
28 
29 #include "data/cpu.h"
30 #include <algorithm>
31 #include <functional>
32 #include "aextrema_finder.h"
33 
37 namespace ExtremaFinder {
38 
39 template<typename T>
41 public:
43  setDefault();
44  }
45 
47  release();
48  }
49 
51  SingleExtremaFinder& operator=(const SingleExtremaFinder& other) = delete;
54  m_cpu = o.m_cpu;
55  // clean original
56  o.setDefault();
57  }
58 
59  static void sFindMax(const CPU &cpu,
60  const Dimensions &dims,
61  const T *data,
62  float *positions,
63  T *values);
64 
65  static void sFindLowest(const CPU &cpu,
66  const Dimensions &dims,
67  const T *data,
68  float *positions,
69  T *values);
70 
71  template<typename C>
72  static void sFindUniversal2DAroundCenter(
73  const C &comp,
74  T startVal,
75  const CPU &cpu,
76  const Dimensions &dims,
77  const T *data,
78  float *positions, // can be nullptr
79  T * values, // can be nullptr
80  size_t maxDist);
81 
82  static void sFindMax2DAroundCenter(const CPU &cpu,
83  const Dimensions &dims,
84  const T *data,
85  float *positions, // can be nullptr
86  T * values, // can be nullptr
87  size_t maxDist);
88 
89  static void sFindLowest2DAroundCenter(const CPU &cpu,
90  const Dimensions &dims,
91  const T *data,
92  float *positions, // can be nullptr
93  T * values, // can be nullptr
94  size_t maxDist);
95 
96 private:
97  CPU *m_cpu; // FIXME DS eventually use thread pool?
98 
99  void setDefault();
100  void release();
101 
102  void check() const override;
103 
104  void initMax() override;
105  void findMax(const T *data) override;
106  bool canBeReusedMax(const ExtremaFinderSettings &s) const override;
107 
108  void initLowest() override;
109  void findLowest(const T *data) override;
110  bool canBeReusedLowest(const ExtremaFinderSettings &s) const override;
111 
112  void initMaxAroundCenter() override;
113  void findMaxAroundCenter(const T *data) override;
114  bool canBeReusedMaxAroundCenter(const ExtremaFinderSettings &s) const override;
115 
116  void initLowestAroundCenter() override;
117  void findLowestAroundCenter(const T *data) override;
118  bool canBeReusedLowestAroundCenter(const ExtremaFinderSettings &s) const override;
119 
120  static void sFindUniversalChecks(
121  const Dimensions &dims,
122  const T *__restrict__ data,
123  float *__restrict__ positions,
124  T *__restrict__ values);
125 
126  void initBasic();
127  template<typename KERNEL>
128  void findBasic(const T *data, const KERNEL &k);
129 };
130 
131 } /* namespace ExtremaFinder */
133 #endif /* LIBRARIES_RECONSTRUCTION_SINGLE_EXTREMA_FINDER_H_ */
static void sFindLowest(const CPU &cpu, const Dimensions &dims, const T *data, float *positions, T *values)
static void sFindUniversal2DAroundCenter(const C &comp, T startVal, const CPU &cpu, const Dimensions &dims, const T *data, float *positions, T *values, size_t maxDist)
static void sFindLowest2DAroundCenter(const CPU &cpu, const Dimensions &dims, const T *data, float *positions, T *values, size_t maxDist)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
SingleExtremaFinder(SingleExtremaFinder &&o)
static void sFindMax(const CPU &cpu, const Dimensions &dims, const T *data, float *positions, T *values)
SingleExtremaFinder & operator=(const SingleExtremaFinder &other)=delete
Definition: cpu.h:37
static void sFindMax2DAroundCenter(const CPU &cpu, const Dimensions &dims, const T *data, float *positions, T *values, size_t maxDist)