Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

LinearInterpolation Class Template Reference
[Math]

#include <OpenMS/MATH/MISC/LinearInterpolation.h>

List of all members.


Detailed Description

template<typename Key = double, typename Value = Key>
class OpenMS::Math::LinearInterpolation< Key, Value >

Provides access to linearly interpolated values (and derivatives) from discrete data points. Values beyond the given range of data points are implicitly taken as zero.

The input is just a vector of values ("Data"). These are interpreted as the y-coordinates at the x-coordinate positions 0,...,data_.size-1.

The interpolated data can also be scaled and shifted in the x-dimension by an affine mapping. That is, we have "inside" and "outside" x-coordinates. The affine mapping can be specified in two ways:

By default the identity mapping (scale=1, offset=0) is used.

Using the value() and derivative() methods you can sample linearly interpolated values for a given x-coordinate position of the data and the derivative of the data.

See also:
BilinearInterpolation

Public Types

Typedefs
typedef Value value_type
typedef Key key_type
typedef std::vector< value_typecontainer_type
typedef value_type ValueType
typedef key_type KeyType
typedef container_type ContainerType

Public Member Functions

 LinearInterpolation (KeyType scale=1., KeyType offset=0.)
 Constructors and destructor.
 LinearInterpolation (LinearInterpolation const &arg)
 Copy constructor.
LinearInterpolationoperator= (LinearInterpolation const &arg)
 Assignment operator.
 ~LinearInterpolation ()
 Destructor.
Interpolated data
ValueType value (KeyType arg_pos) const throw ()
 Returns the interpolated value.
void addValue (KeyType arg_pos, ValueType arg_value) throw ()
 Performs linear resampling. The arg_value is split up and added to the data points around arg_pos.
ValueType derivative (KeyType arg_pos) const throw ()
 Returns the interpolated derivative.
Discrete (non-interpolated) data
ContainerTypegetData () throw ()
 Returns the internal random access container from which interpolated values are being sampled.
ContainerType const & getData () const throw ()
 Returns the internal random access container from which interpolated values are being sampled.
template<typename SourceContainer>
void setData (SourceContainer const &data) throw ()
 Assigns data to the internal random access container from which interpolated values are being sampled.
bool empty () const throw ()
 Returns true if getData() is empty.
Transformation
KeyType key2index (KeyType pos) const throw ()
 The transformation from "outside" to "inside" coordinates.
KeyType index2key (KeyType pos) const throw ()
 The transformation from "inside" to "outside" coordinates.
KeyType const & getScale () const throw ()
 Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data".
void setScale (KeyType const &scale) throw ()
 Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data".
KeyType const & getOffset () const throw ()
 Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data[0]".
void setOffset (KeyType const &offset) throw ()
 Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data[0]".
void setMapping (KeyType const &scale, KeyType const &inside, KeyType const &outside)
 Specifies the mapping from "outside" to "inside" coordinates by the following data:
  • scale: the difference in outside coordinates between consecutive values in the data vector.
  • inside and outside: these x-axis positions are mapped onto each other.

void setMapping (KeyType const &inside_low, KeyType const &outside_low, KeyType const &inside_high, KeyType const &outside_high)
 Specifies the mapping from "outside" to "inside" coordinates by the following data:
  • inside_low and outside_low: these axis positions are mapped onto each other.
  • inside_high and outside_high: these axis positions are mapped onto each other.

KeyType const & getInsideReferencePoint () const throw ()
 Accessor. See setMapping().
KeyType const & getOutsideReferencePoint () const throw ()
 Accessor. See setMapping().
KeyType supportMin () const throw ()
 Lower boundary of the support, in "outside" coordinates.
KeyType supportMax () const throw ()
 Upper boundary of the support, in "outside" coordinates.

Protected Attributes

KeyType scale_
KeyType offset_
KeyType inside_
KeyType outside_
ContainerType data_

Member Typedef Documentation

typedef Value value_type

typedef Key key_type

typedef std::vector< value_type > container_type

typedef value_type ValueType

typedef key_type KeyType

typedef container_type ContainerType


Constructor & Destructor Documentation

LinearInterpolation ( KeyType  scale = 1.,
KeyType  offset = 0. 
) [inline]

Constructors and destructor.

The first argument is the scale which is applied to the arguments of value() and derivative() before looking up the interpolated values in the container. The second argument is the offset, which is subtracted before everything else.

LinearInterpolation ( LinearInterpolation< Key, Value > const &  arg  )  [inline]

Copy constructor.

~LinearInterpolation (  )  [inline]

Destructor.


Member Function Documentation

LinearInterpolation& operator= ( LinearInterpolation< Key, Value > const &  arg  )  [inline]

Assignment operator.

ValueType value ( KeyType  arg_pos  )  const throw () [inline]

Returns the interpolated value.

void addValue ( KeyType  arg_pos,
ValueType  arg_value 
) throw () [inline]

Performs linear resampling. The arg_value is split up and added to the data points around arg_pos.

ValueType derivative ( KeyType  arg_pos  )  const throw () [inline]

Returns the interpolated derivative.

Please drop me (= the maintainer) a message if you are using this.

ContainerType& getData (  )  throw () [inline]

Returns the internal random access container from which interpolated values are being sampled.

ContainerType const& getData (  )  const throw () [inline]

Returns the internal random access container from which interpolated values are being sampled.

void setData ( SourceContainer const &  data  )  throw () [inline]

Assigns data to the internal random access container from which interpolated values are being sampled.

SourceContainer must be assignable to ContainerType.

bool empty (  )  const throw () [inline]

Returns true if getData() is empty.

KeyType key2index ( KeyType  pos  )  const throw () [inline]

The transformation from "outside" to "inside" coordinates.

KeyType index2key ( KeyType  pos  )  const throw () [inline]

The transformation from "inside" to "outside" coordinates.

KeyType const& getScale (  )  const throw () [inline]

Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data".

void setScale ( KeyType const &  scale  )  throw () [inline]

Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data".

Note: Using this invalidates the inside and outside reference points.

KeyType const& getOffset (  )  const throw () [inline]

Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data[0]".

void setOffset ( KeyType const &  offset  )  throw () [inline]

Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data[0]".

Note: Using this invalidates the inside and outside reference points.

void setMapping ( KeyType const &  scale,
KeyType const &  inside,
KeyType const &  outside 
) [inline]

Specifies the mapping from "outside" to "inside" coordinates by the following data:

For example, when you have a complicated probability distribution which is in fact centered around zero (but you cannot have negative indices in the data vector), then you can arrange things such that inside is the mean of the pre-computed, shifted density values of that distribution and outside is the centroid position of, say, a peak in the real world which you want to model by a scaled and shifted version of the probability distribution.

void setMapping ( KeyType const &  inside_low,
KeyType const &  outside_low,
KeyType const &  inside_high,
KeyType const &  outside_high 
) [inline]

Specifies the mapping from "outside" to "inside" coordinates by the following data:

This four argument version is just a convenience overload for the three argument version, which see.

KeyType const& getInsideReferencePoint (  )  const throw () [inline]

Accessor. See setMapping().

KeyType const& getOutsideReferencePoint (  )  const throw () [inline]

Accessor. See setMapping().

KeyType supportMin (  )  const throw () [inline]

Lower boundary of the support, in "outside" coordinates.

KeyType supportMax (  )  const throw () [inline]

Upper boundary of the support, in "outside" coordinates.


Member Data Documentation

KeyType scale_ [protected]

KeyType offset_ [protected]

KeyType inside_ [protected]

KeyType outside_ [protected]

ContainerType data_ [protected]


The documentation for this class was generated from the following file:
Generated Tue Apr 1 15:36:49 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1