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

#include <linterp.h>

Inheritance diagram for InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >:
Inheritance graph
[legend]
Collaboration diagram for InterpMultilinear< 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 >
 InterpMultilinear (IterT1 grids_begin, IterT2 grids_len_begin, IterT3 f_begin, IterT3 f_end)
 
template<class IterT1 , class IterT2 , class IterT3 , class RefCountIterT >
 InterpMultilinear (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
 

Static Public Member Functions

template<class IterT1 , class IterT2 >
static T linterp_nd_unitcube (IterT1 f_begin, IterT1 f_end, IterT2 xi_begin, IterT2 xi_end)
 

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 InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >

Definition at line 296 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> InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::super

Definition at line 298 of file linterp.h.

Constructor & Destructor Documentation

◆ InterpMultilinear() [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 >
InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::InterpMultilinear ( IterT1  grids_begin,
IterT2  grids_len_begin,
IterT3  f_begin,
IterT3  f_end 
)
inline

Definition at line 301 of file linterp.h.

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

◆ InterpMultilinear() [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 >
InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::InterpMultilinear ( IterT1  grids_begin,
IterT2  grids_len_begin,
IterT3  f_begin,
IterT3  f_end,
ArrayRefCountT &  refF,
RefCountIterT  ref_begins 
)
inline

Definition at line 305 of file linterp.h.

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

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 InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::interp ( IterT  x_begin) const
inline

Definition at line 327 of file linterp.h.

327  {
328  array<T,1> result;
329  array< array<T,1>, N > coord_iter;
330  for (int i=0; i<N; i++) {
331  coord_iter[i][0] = x_begin[i];
332  }
333  interp_vec(1, coord_iter.begin(), coord_iter.end(), result.begin());
334  return result[0];
335  }
void interp_vec(int n, IterT1 coord_iter_begin, IterT1 coord_iter_end, IterT2 i_result) const
Definition: linterp.h:338

◆ 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 InterpMultilinear< 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 338 of file linterp.h.

338  {
339  assert(N == coord_iter_end - coord_iter_begin);
340  array<int,N> index;
341  int c;
342  T y, xi;
343  vector<T> f(1 << N);
344  array<T,N> x;
345 
346  for (int i=0; i<n; i++) { // loop over each point
347  for (int dim=0; dim<N; dim++) { // loop over each dimension
348  auto const &grid(super::m_grid_list[dim]);
349  xi = coord_iter_begin[dim][i];
350  c = this->find_cell(dim, coord_iter_begin[dim][i]);
351  if (c == -1) { // before first grid point
352  y = 1.0;
353  } else if (c == grid.size()-1) { // after last grid point
354  y = 0.0;
355  } else {
356  y = (coord_iter_begin[dim][i] - grid[c]) / (grid[c + 1] - grid[c]);
357  if (y < 0.0) y=0.0;
358  else if (y > 1.0) y=1.0;
359  }
360  index[dim] = c;
361  x[dim] = y;
362  }
363  // copy f values at vertices
364  for (int v=0; v < (1 << N); v++) { // loop over each vertex of hypercube
365  f[v] = this->get_f_val(index, v);
366  }
367  *i_result++ = linterp_nd_unitcube(f.begin(), f.end(), x.begin(), x.end());
368  }
369  }
T get_f_val(array< int, N > const &cell_index, array< int, N > const &v_index) const
Definition: linterp.h:185
int find_cell(int dim, T x) const
Definition: linterp.h:174
static T linterp_nd_unitcube(IterT1 f_begin, IterT1 f_end, IterT2 xi_begin, IterT2 xi_end)
Definition: linterp.h:310
vector< grid_type > m_grid_list
Definition: linterp.h:89

◆ linterp_nd_unitcube()

template<int N, class T , bool CopyData = true, bool Continuous = true, class ArrayRefCountT = EmptyClass, class GridRefCountT = EmptyClass>
template<class IterT1 , class IterT2 >
static T InterpMultilinear< N, T, CopyData, Continuous, ArrayRefCountT, GridRefCountT >::linterp_nd_unitcube ( IterT1  f_begin,
IterT1  f_end,
IterT2  xi_begin,
IterT2  xi_end 
)
inlinestatic

Definition at line 310 of file linterp.h.

310  {
311  int n = xi_end - xi_begin;
312  int f_len = f_end - f_begin;
313  assert(1 << n == f_len);
314  T sub_lower, sub_upper;
315  if (n == 1) {
316  sub_lower = f_begin[0];
317  sub_upper = f_begin[1];
318  } else {
319  sub_lower = linterp_nd_unitcube(f_begin, f_begin + (f_len/2), xi_begin + 1, xi_end);
320  sub_upper = linterp_nd_unitcube(f_begin + (f_len/2), f_end, xi_begin + 1, xi_end);
321  }
322  T result = sub_lower + (*xi_begin)*(sub_upper - sub_lower);
323  return result;
324  }
static T linterp_nd_unitcube(IterT1 f_begin, IterT1 f_end, IterT2 xi_begin, IterT2 xi_end)
Definition: linterp.h:310

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