Xmipp  v3.23.11-Nereus
ashift_corr_estimator.cpp
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 #include "ashift_corr_estimator.h"
26 
27 namespace Alignment {
28 
29 template<typename T>
32 
33  m_settingsInv = nullptr;
34  m_centerSize = 0;
35 
36  // flags
37  m_includingBatchFT = false;
38  m_includingSingleFT = false;
39  m_is_ref_FD_loaded = false;
40  m_allowDataOverwrite = false;
41 }
42 
43 template<typename T>
45  delete m_settingsInv;
47 
49 }
50 
51 template<typename T>
53  const FFTSettings<T> &dims, size_t maxShift,
54  bool includingBatchFT, bool includingSingleFT,
55  bool allowDataOverwrite) {
56  AShiftEstimator<T>::init2D(type, dims.sDim(), dims.batch(), maxShift);
57 
58  m_settingsInv = new FFTSettings<T>(dims.isForward() ? dims.createInverse() : dims);
59  m_includingBatchFT = includingBatchFT;
60  m_includingSingleFT = includingSingleFT;
61  m_centerSize = 2 * maxShift + 1;
62  m_allowDataOverwrite = allowDataOverwrite;
63 
64  this->check();
65 
66  switch (type) {
67  case AlignType::OneToN:
68  init2DOneToN();
69  break;
70  default:
71  REPORT_ERROR(ERR_NOT_IMPLEMENTED, "This alignment type is not supported yet");
72  }
73 }
74 
75 template<typename T>
77  using memoryUtils::operator "" _GB;
78 
79  if (this->m_settingsInv->fBytesBatch() >= 4_GB) {
80  REPORT_ERROR(ERR_VALUE_INCORRECT, "Batch is bigger than max size (4GB)");
81  }
82  if ((0 != (this->m_settingsInv->sDim().x() % 2))
83  || (0 != (this->m_settingsInv->sDim().y() % 2))) {
84  // while performing IFT of the correlation, we center the signal using multiplication
85  // in the FD. This, however, works only for even signal.
87  "The X and Y dimensions have to be multiple of two. Crop your signal");
88  }
89 }
90 
91 // explicit instantiation
92 template class AShiftCorrEstimator<float>;
93 template class AShiftCorrEstimator<double>;
94 
95 } /* namespace Alignment */
Case or algorithm not implemented yet.
Definition: xmipp_error.h:177
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
virtual void init2D(const std::vector< HW *> &hw, AlignType type, const FFTSettings< T > &dims, size_t maxShift, bool includingBatchFT, bool includingSingleFT, bool allowDataOverwrite)=0
virtual void init2D(const std::vector< HW *> &hw, AlignType type, const Dimensions &dims, size_t batch, size_t maxShift)=0
constexpr size_t batch() const
Definition: fft_settings.h:86
viol type
FFTSettings< T > createInverse() const
Definition: fft_settings.h:134
constexpr Dimensions sDim() const
Definition: fft_settings.h:78
constexpr bool isForward() const
Definition: fft_settings.h:122
Incorrect value received.
Definition: xmipp_error.h:195
check(nparam, nf, nfsr, &Linfty, nineq, nineqn, neq, neqn, ncsrl, ncsrn, mode, &modem, eps, bgbnd, param)