icedb  version 0.5.1
Snow particle scattering database API
Public Types | Public Member Functions | List of all members
InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT > Class Template Reference

#include <linterp.h>

Inheritance diagram for InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >:
Inheritance graph
[legend]
Collaboration diagram for InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >:
Collaboration graph
[legend]

Public Types

typedef NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT > super
 
- Public Types inherited from NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >
typedef T value_type
 
typedef ArrayRefCountT array_ref_count_type
 
typedef GridRefCountT grid_ref_count_type
 
typedef boost::numeric::ublas::array_adaptor< T > grid_type
 
typedef boost::const_multi_array_ref< T, N > array_type
 
typedef std::unique_ptr< array_typearray_type_ptr
 

Public Member Functions

template<class IterT1 , class IterT2 , class IterT3 >
 InterpSimplex (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end)
 
template<class IterT1 , class IterT2 , class IterT3 , class RefCountIterT >
 InterpSimplex (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT ref_begins)
 
template<class IterT >
interp (IterT x_begin) const
 
template<class IterT1 , class IterT2 >
void interp_vec (int n, IterT1 coord_iter_begin, IterT1 coord_iter_end, IterT2 i_result) const
 
- Public Member Functions inherited from NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >
template<class IterT1 , class IterT2 , class IterT3 >
 NDInterpolator (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end)
 
template<class IterT1 , class IterT2 , class IterT3 , class RefCountIterT >
 NDInterpolator (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT grid_refs_begin)
 
template<class IterT1 , class IterT2 , class IterT3 >
void init (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end)
 
template<class IterT1 , class IterT2 , class IterT3 , class RefCountIterT >
void init_refcount (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end, ArrayRefCountT &refF, RefCountIterT grid_refs_begin)
 
template<class IterT1 , class IterT2 >
void set_grids (IterT1 grids_begin, IterT2 grids_len_begin, bool bCopy)
 
template<class IterT1 , class RefCountIterT >
void set_grids_refcount (RefCountIterT refs_begin, RefCountIterT refs_end)
 
template<class IterT >
void set_f_array (IterT f_begin, IterT f_end, bool bCopy)
 
void set_f_refcount (ArrayRefCountT &refF)
 
int find_cell (int dim, T x) const
 
get_f_val (array< int, N > const &cell_index, array< int, N > const &v_index) const
 
get_f_val (array< int, N > const &cell_index, int v) const
 

Additional Inherited Members

- Public Attributes inherited from NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >
array_type_ptr m_pF
 
ArrayRefCountT m_ref_F
 
vector< T > m_F_copy
 
vector< grid_typem_grid_list
 
vector< GridRefCountT > m_grid_ref_list
 
vector< vector< T > > m_grid_copy_list
 
- Static Public Attributes inherited from NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >
static const int m_N = N
 
static const bool m_bCopyData = CopyData
 
static const bool m_bContinuous = Continuous
 

Detailed Description

template<int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
class InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >

Definition at line 222 of file linterp.h.

Member Typedef Documentation

◆ super

template<int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
typedef NDInterpolator<N,T,CopyData,Continuous,ArrayRefCountT,GridRefCountT> InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::super

Definition at line 224 of file linterp.h.

Constructor & Destructor Documentation

◆ InterpSimplex() [1/2]

template<int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
template<class IterT1 , class IterT2 , class IterT3 >
InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::InterpSimplex ( IterT1  grids_begin,
IterT2  grids_len_begin,
IterT3  f_begin,
IterT3  f_end 
)
inline

Definition at line 227 of file linterp.h.

228  : super(grids_begin, grids_len_begin, f_begin, f_end)
229  {}
NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT > super
Definition: linterp.h:224

◆ InterpSimplex() [2/2]

template<int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
template<class IterT1 , class IterT2 , class IterT3 , class RefCountIterT >
InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::InterpSimplex ( IterT1  grids_begin,
IterT2  grids_len_begin,
IterT3  f_begin,
IterT3  f_end,
ArrayRefCountT &  refF,
RefCountIterT  ref_begins 
)
inline

Definition at line 231 of file linterp.h.

232  : super(grids_begin, grids_len_begin, f_begin, f_end, refF, ref_begins)
233  {}
NDInterpolator< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT > super
Definition: linterp.h:224

Member Function Documentation

◆ interp()

template<int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
template<class IterT >
T InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::interp ( IterT  x_begin) const
inline

Definition at line 236 of file linterp.h.

236  {
237  array<T,1> result;
238  array< array<T,1>, N > coord_iter;
239  for (int i=0; i<N; i++) {
240  coord_iter[i][0] = x_begin[i];
241  }
242  interp_vec(1, coord_iter.begin(), coord_iter.end(), result.begin());
243  return result[0];
244  }
void interp_vec(int n, IterT1 coord_iter_begin, IterT1 coord_iter_end, IterT2 i_result) const
Definition: linterp.h:247

◆ interp_vec()

template<int N, class T, bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
template<class IterT1 , class IterT2 >
void InterpSimplex< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::interp_vec ( int  n,
IterT1  coord_iter_begin,
IterT1  coord_iter_end,
IterT2  i_result 
) const
inline

Definition at line 247 of file linterp.h.

Referenced by linterp_simplex_1(), linterp_simplex_2(), and linterp_simplex_3().

247  {
248  assert(N == coord_iter_end - coord_iter_begin);
249 
250  array<int,N> cell_index, v_index;
251  array<std::pair<T, int>,N> xipair;
252  int c;
253  T y, v0, v1;
254  //mexPrintf("%d\n", n);
255  for (int i=0; i<n; i++) { // for each point
256  for (int dim=0; dim<N; dim++) {
257  typename super::grid_type const &grid(super::m_grid_list[dim]);
258  c = this->find_cell(dim, coord_iter_begin[dim][i]);
259  //mexPrintf("%d\n", c);
260  if (c == -1) { // before first grid point
261  y = 1.0;
262  } else if (c == grid.size()-1) { // after last grid point
263  y = 0.0;
264  } else {
265  //mexPrintf("%f %f\n", grid[c], grid[c+1]);
266  y = (coord_iter_begin[dim][i] - grid[c]) / (grid[c + 1] - grid[c]);
267  if (y < 0.0) y=0.0;
268  else if (y > 1.0) y=1.0;
269  }
270  xipair[dim].first = y;
271  xipair[dim].second = dim;
272  cell_index[dim] = c;
273  }
274  // sort xi's and get the permutation
275  std::sort(xipair.begin(), xipair.end(), [](std::pair<T, int> const &a, std::pair<T, int> const &b) {
276  return (a.first < b.first);
277  });
278  // walk the vertices of the simplex determined by the permutation
279  for (int j=0; j<N; j++) {
280  v_index[j] = 1;
281  }
282  v0 = this->get_f_val(cell_index, v_index);
283  y = v0;
284  for (int j=0; j<N; j++) {
285  v_index[xipair[j].second]--;
286  v1 = this->get_f_val(cell_index, v_index);
287  y += (1.0 - xipair[j].first) * (v1-v0); // interpolate
288  v0 = v1;
289  }
290  *i_result++ = y;
291  }
292  }
T get_f_val(array< int, N > const &cell_index, array< int, N > const &v_index) const
Definition: linterp.h:185
boost::numeric::ublas::array_adaptor< T > grid_type
Definition: linterp.h:81
int find_cell(int dim, T x) const
Definition: linterp.h:174
vector< grid_type > m_grid_list
Definition: linterp.h:89
Here is the caller graph for this function:

The documentation for this class was generated from the following file: