INET Framework for OMNeT++/OMNEST
inet::physicallayer::Linear< _ContainerType > Class Template Reference

Given two iterators defining a range of key-value-pairs this class provides linear interpolation of the value at an arbitrary key-position. More...

#include <Interpolation.h>

Inheritance diagram for inet::physicallayer::Linear< _ContainerType >:
inet::physicallayer::InterpolatorBase< _ContainerType >

Public Types

typedef base_class_type::storage_type storage_type
 
typedef base_class_type::container_type container_type
 
typedef base_class_type::key_type key_type
 
typedef base_class_type::key_cref_type key_cref_type
 
typedef base_class_type::mapped_type mapped_type
 
typedef base_class_type::mapped_cref_type mapped_cref_type
 
typedef base_class_type::pair_type pair_type
 
typedef base_class_type::iterator iterator
 
typedef base_class_type::const_iterator const_iterator
 
typedef base_class_type::comparator_type comparator_type
 
typedef base_class_type::interpolated interpolated
 
- Public Types inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
typedef _ContainerType storage_type
 
typedef storage_type container_type
 
typedef storage_type::key_type key_type
 
typedef const key_typekey_cref_type
 
typedef storage_type::mapped_type mapped_type
 
typedef const mapped_typemapped_cref_type
 
typedef storage_type::value_type pair_type
 
typedef storage_type::iterator iterator
 
typedef storage_type::const_iterator const_iterator
 
typedef PairLess< pair_type, key_typecomparator_type
 
typedef Interpolated< mapped_typeinterpolated
 

Public Member Functions

 Linear ()
 
 Linear (mapped_cref_type oorv)
 
virtual ~Linear ()
 
virtual interpolated operator() (const const_iterator &first, const const_iterator &last, key_cref_type pos, const_iterator upperBound) const
 Functor operator of this class which linear interpolates the value at the passed position using the values between the passed Iterators. More...
 
- Public Member Functions inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
 InterpolatorBase ()
 
 InterpolatorBase (mapped_cref_type oorv)
 
virtual ~InterpolatorBase ()
 
bool continueAtOutOfRange (void) const
 
interpolated operator() (const const_iterator &first, const const_iterator &last, key_cref_type pos) const
 Functor operator of this class which interpolates the value at the passed position using the values between the passed Iterators. More...
 
virtual bool isStepping () const
 Represents the interpolator a stepping function. More...
 
void setOutOfRangeVal (mapped_cref_type oorv)
 Getter and Setter method for out of range value. More...
 
mapped_cref_type getOutOfRangeVal (void) const
 

Protected Types

typedef InterpolatorBase< _ContainerType > base_class_type
 

Static Protected Member Functions

static mapped_type linearInterpolationFactor (key_cref_type t, key_cref_type t0, key_cref_type t1)
 Calculates the linear interpolation factor used for the interpolation. More...
 
static mapped_type linearInterpolation (key_cref_type t, key_cref_type t0, key_cref_type t1, mapped_cref_type v0, mapped_cref_type v1)
 

Additional Inherited Members

- Public Attributes inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
comparator_type comp
 Comparator for STL functions. More...
 
- Protected Member Functions inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
interpolated asInterpolated (mapped_cref_type rVal, bool bIsOutOfRange, bool bIsInterpolated=true) const
 
- Protected Attributes inherited from inet::physicallayer::InterpolatorBase< _ContainerType >
bool continueOutOfRange
 
interpolated outOfRangeVal
 

Detailed Description

template<class _ContainerType>
class inet::physicallayer::Linear< _ContainerType >

Given two iterators defining a range of key-value-pairs this class provides linear interpolation of the value at an arbitrary key-position.

Author
Karl Wessel

Member Typedef Documentation

template<class _ContainerType>
typedef InterpolatorBase<_ContainerType> inet::physicallayer::Linear< _ContainerType >::base_class_type
protected
template<class _ContainerType>
typedef base_class_type::comparator_type inet::physicallayer::Linear< _ContainerType >::comparator_type
template<class _ContainerType>
typedef base_class_type::const_iterator inet::physicallayer::Linear< _ContainerType >::const_iterator
template<class _ContainerType>
typedef base_class_type::container_type inet::physicallayer::Linear< _ContainerType >::container_type
template<class _ContainerType>
typedef base_class_type::interpolated inet::physicallayer::Linear< _ContainerType >::interpolated
template<class _ContainerType>
typedef base_class_type::iterator inet::physicallayer::Linear< _ContainerType >::iterator
template<class _ContainerType>
typedef base_class_type::key_cref_type inet::physicallayer::Linear< _ContainerType >::key_cref_type
template<class _ContainerType>
typedef base_class_type::key_type inet::physicallayer::Linear< _ContainerType >::key_type
template<class _ContainerType>
typedef base_class_type::mapped_cref_type inet::physicallayer::Linear< _ContainerType >::mapped_cref_type
template<class _ContainerType>
typedef base_class_type::mapped_type inet::physicallayer::Linear< _ContainerType >::mapped_type
template<class _ContainerType>
typedef base_class_type::pair_type inet::physicallayer::Linear< _ContainerType >::pair_type
template<class _ContainerType>
typedef base_class_type::storage_type inet::physicallayer::Linear< _ContainerType >::storage_type

Constructor & Destructor Documentation

template<class _ContainerType>
inet::physicallayer::Linear< _ContainerType >::Linear ( )
inline
448  :
449  base_class_type() {}
InterpolatorBase< _ContainerType > base_class_type
Definition: Interpolation.h:432
template<class _ContainerType>
inet::physicallayer::Linear< _ContainerType >::Linear ( mapped_cref_type  oorv)
inline
451  :
452  base_class_type(oorv) {}
InterpolatorBase< _ContainerType > base_class_type
Definition: Interpolation.h:432
template<class _ContainerType>
virtual inet::physicallayer::Linear< _ContainerType >::~Linear ( )
inlinevirtual
454 {}

Member Function Documentation

template<class _ContainerType>
static mapped_type inet::physicallayer::Linear< _ContainerType >::linearInterpolation ( key_cref_type  t,
key_cref_type  t0,
key_cref_type  t1,
mapped_cref_type  v0,
mapped_cref_type  v1 
)
inlinestaticprotected
512  {
513  typedef std::numeric_limits<mapped_type> tnumlimits_for_v;
514 
515  if (tnumlimits_for_v::has_infinity) {
516  // we have possible infinity values, so that we can do some checks
517  const mapped_type cInf = tnumlimits_for_v::infinity();
518  const bool bV0IsInf = (v0 == cInf) || (tnumlimits_for_v::is_signed ? (v0 == -cInf) : false);
519 
520  if (bV0IsInf || (v1 == cInf) || (tnumlimits_for_v::is_signed ? (v1 == -cInf) : false)) {
521  if (tnumlimits_for_v::is_signed && (v1 == -v0)) {
522  // v0 == +/-Inf and v1 == -/+Inf
523  if (tnumlimits_for_v::has_quiet_NaN)
524  return tnumlimits_for_v::quiet_NaN();
525  // mhhh!? No quiet_NaN available, so we fall back to old
526  // handling :(
527  }
528  else {
529  // the result should be infinity
530  return bV0IsInf ? v0 : v1;
531  }
532  }
533  }
534  assert((t0 <= t && t <= t1) || (t0 >= t && t >= t1));
535  if (t0 == t1) {
536  assert(v0 == v1);
537  return v0;
538  }
539  const mapped_type mu = linearInterpolationFactor(t, t0, t1);
540 
541  return v0 * (static_cast<mapped_type>(1) - mu) + v1 * mu;
542  //return v0 + (((v1 - v0) * (t - t0)) / (t1 - t0));
543  }
base_class_type::mapped_type mapped_type
Definition: Interpolation.h:439
static mapped_type linearInterpolationFactor(key_cref_type t, key_cref_type t0, key_cref_type t1)
Calculates the linear interpolation factor used for the interpolation.
Definition: Interpolation.h:500
const value< double, units::kg > mu(1.660538782e-27)
template<class _ContainerType>
static mapped_type inet::physicallayer::Linear< _ContainerType >::linearInterpolationFactor ( key_cref_type  t,
key_cref_type  t0,
key_cref_type  t1 
)
inlinestaticprotected

Calculates the linear interpolation factor used for the interpolation.

501  {
502  assert((t0 <= t && t <= t1) || (t0 >= t && t >= t1));
503  if (t0 == t1) {
504  return 0;
505  }
506  return cast_it<mapped_type>((t - t0) / (t1 - t0));
507  }
template<class _ContainerType>
virtual interpolated inet::physicallayer::Linear< _ContainerType >::operator() ( const const_iterator first,
const const_iterator last,
key_cref_type  pos,
const_iterator  upperBound 
) const
inlinevirtual

Functor operator of this class which linear interpolates the value at the passed position using the values between the passed Iterators.

The upperBound-iterator has to point to the entry next bigger as the passed position to interpolate.

The returned instance of interpolated represents the result. Which can be either an actual entry of the interpolated map (if the position two interpolate was exactly that. Or it can be an interpolated value, if the passed position was between two entries of the map. This state can be retrieved with the "isInterpolated"-Member of the returned "interpolated".

Implements inet::physicallayer::InterpolatorBase< _ContainerType >.

475  {
476  if (first == last) {
478  }
479  if (upperBound == first) {
480  return this->asInterpolated(upperBound->second, true);
481  }
482 
483  const_iterator right = upperBound;
484  const_iterator left = --upperBound;
485 
486  if (left->first == pos)
487  return this->asInterpolated(left->second, false, false);
488 
489  if (right == last) {
490  return this->asInterpolated(left->second, true);
491  }
492 
493  return interpolated(linearInterpolation(pos, left->first, right->first, left->second, right->second));
494  }
base_class_type::const_iterator const_iterator
Definition: Interpolation.h:443
interpolated outOfRangeVal
Definition: Interpolation.h:153
interpolated asInterpolated(mapped_cref_type rVal, bool bIsOutOfRange, bool bIsInterpolated=true) const
Definition: Interpolation.h:235
static mapped_type linearInterpolation(key_cref_type t, key_cref_type t0, key_cref_type t1, mapped_cref_type v0, mapped_cref_type v1)
Definition: Interpolation.h:509
base_class_type::interpolated interpolated
Definition: Interpolation.h:445

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