STIR  6.2.0
BSplines1DRegularGrid.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2005 - 2009-10-27, Hammersmith Imanet Ltd
3  Copyright (C) 2013, University College London
4  This file is part of STIR.
5 
6  SPDX-License-Identifier: Apache-2.0
7 
8  See STIR/LICENSE.txt for details
9 */
10 #ifndef __stir_numerics_BSplines1DRegularGrid__H__
11 #define __stir_numerics_BSplines1DRegularGrid__H__
12 
22 #include "stir/numerics/BSplines.h"
23 #include <vector>
24 
25 START_NAMESPACE_STIR
26 
27 namespace BSpline
28 {
29 
37 template <typename out_elemT, typename in_elemT = out_elemT, typename constantsT = in_elemT>
39 {
40 private:
41  typedef typename std::vector<out_elemT>::iterator RandIterOut;
42  int input_size; // create in the constructor
43  constantsT z1;
44  constantsT z2;
45  constantsT lambda;
46 
47  inline out_elemT BSplines_product(const int index, const pos_type relative_position, const bool if_deriv) const;
48 
49  inline void set_private_values(BSplineType);
50 
51  inline out_elemT compute_BSplines_value(const pos_type relative_position, const bool if_deriv) const;
52 
53  // sadly,VC6.0 needs definition of template members in the class definition
54  template <class IterT>
55  inline void set_coef(IterT input_begin_iterator, IterT input_end_iterator)
56  {
57  BSplines1DRegularGrid::input_size = static_cast<int>(input_end_iterator - input_begin_iterator);
58  BSplines_coef_vector.resize(input_size);
60  BSplines_coef_vector.begin(), BSplines_coef_vector.end(), input_begin_iterator, input_end_iterator, z1, z2, lambda);
61  }
62 
63 public:
64  std::vector<out_elemT> BSplines_coef_vector;
65  BSplineType spline_type;
66 
68  inline BSplines1DRegularGrid();
69 
71  inline explicit BSplines1DRegularGrid(const std::vector<in_elemT>& input_vector);
72 
74  template <class IterT>
75  inline BSplines1DRegularGrid(const IterT input_begin_iterator, const IterT input_end_iterator)
76  {
77  set_private_values(cubic);
78  set_coef(input_begin_iterator, input_end_iterator);
79  }
81  template <class IterT>
82  inline BSplines1DRegularGrid(const IterT input_begin_iterator, const IterT input_end_iterator, const BSplineType this_type)
83  {
84  set_private_values(this_type);
85  set_coef(input_begin_iterator, input_end_iterator);
86  }
87 
88  inline BSplines1DRegularGrid(const std::vector<in_elemT>& input_vector, const BSplineType this_type);
89 
91  inline ~BSplines1DRegularGrid();
92 
93  inline out_elemT BSplines(const pos_type relative_position) const;
94 
95  inline out_elemT BSplines_1st_der(const pos_type relative_position) const;
96 
98  inline const out_elemT operator()(const pos_type relative_position) const;
99 
100  inline const std::vector<out_elemT>
101  BSplines_output_sequence(RandIterOut output_relative_position_begin_iterator, // relative_position might be better float
102  RandIterOut output_relative_position_end_iterator);
103  inline const std::vector<out_elemT> BSplines_output_sequence(std::vector<pos_type> output_relative_position);
104 };
105 } // namespace BSpline
106 
107 END_NAMESPACE_STIR
108 
110 
111 #endif
void BSplines_coef(RandIterOut c_begin_iterator, RandIterOut c_end_iterator, IterT input_begin_iterator, IterT input_end_iterator, const constantsT z1, const constantsT z2, const constantsT lambda)
compute BSpline coefficients that gives the BSpline that interpolates the given data ...
Definition: BSplines_coef.inl:56
BSplineType
enum providing constants to define the type of B-Spline used for interpolation
Definition: BSplines.h:37
double pos_type
The type used for relative positions between the grid points.
Definition: BSplines.h:32
Temporary class for 1D B-splines.
Definition: BSplines1DRegularGrid.h:38
Implementation of the B-Splines Interpolation.
Implementation of the basic components and declarations for B-Splines Interpolation.
BSplines1DRegularGrid(const IterT input_begin_iterator, const IterT input_end_iterator, const BSplineType this_type)
constructor given a begin_ and end_ iterator as input, estimates the Coefficients ...
Definition: BSplines1DRegularGrid.h:82
BSplines1DRegularGrid(const IterT input_begin_iterator, const IterT input_end_iterator)
constructor given a begin_ and end_ iterator as input, estimates the Coefficients ...
Definition: BSplines1DRegularGrid.h:75