Xmipp  v3.23.11-Nereus
bspline_helper.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_BSPLINE_HELPER_H_
27 #define LIBRARIES_RECONSTRUCTION_BSPLINE_HELPER_H_
28 
30 #include "data/dimensions.h"
31 #include "eq_system_solver.h"
32 #include "data/bspline_grid.h"
33 #include "core/matrix2d.h"
34 #include <iosfwd>
35 #include <utility> // std::make_pair
36 #include <type_traits>
37 
42 public:
53  template<typename T>
54  static std::pair<Matrix1D<T>, Matrix1D<T>> computeBSplineCoeffs(const Dimensions &movieSize,
55  const LocalAlignmentResult<T> &alignment,
56  const Dimensions &controlPoints, const std::pair<size_t, size_t> &noOfPatches,
57  int verbosity, int solverIters);
58 
68  template<typename T>
69  static std::pair<T, T> getShift(const BSplineGrid<T> &grid, Dimensions dim,
70  size_t x, size_t y, size_t n);
71 
76  // FIXME unify with CUDA implementation
77  template<typename T>
78  static inline T Bspline03(T argument) {
79 
80  static_assert(std::is_same<float, T>::value
81  || std::is_same<double, T>::value, "T must be either float or double");
82  if (std::is_same<float, T>::value) {
83  argument = fabsf(argument);
84  } else {
85  argument = fabs(argument);
86  }
87  if (argument < (T)1) {
88  return(argument * argument * (argument - (T)2) * (T)0.5 + (T)2 / (T)3);
89  }
90  else if (argument < (T)2) {
91  argument -= (T)2;
92  return(argument * argument * argument * ((T)-1 / (T)6));
93  }
94  else {
95  return (T)0;
96  }
97  }
98 
115  // FIXME unify with CUDA implementation
116  template<typename T>
117  static void getShift(int lX, int lY, int lN,
118  int xdim, int ydim, int ndim,
119  int x, int y, int n,
120  T &shiftY, T &shiftX,
121  const T *coeffsX, const T *coeffsY);
122 };
124 #endif /* LIBRARIES_RECONSTRUCTION_BSPLINE_HELPER_H_ */
static std::pair< T, T > getShift(const BSplineGrid< T > &grid, Dimensions dim, size_t x, size_t y, size_t n)
static double * y
static T Bspline03(T argument)
doublereal * x
static std::pair< Matrix1D< T >, Matrix1D< T > > computeBSplineCoeffs(const Dimensions &movieSize, const LocalAlignmentResult< T > &alignment, const Dimensions &controlPoints, const std::pair< size_t, size_t > &noOfPatches, int verbosity, int solverIters)
Definition: ctf.h:38
int * n