| OpenMS 2.5.0

List of all members
BilinearInterpolation< Key, Value > Class Template Reference
Math

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

`#include <OpenMS/MATH/MISC/BilinearInterpolation.h>`

## Public Types

Typedefs
typedef Value | value_type
typedef Key | key_type
typedef Matrix< value_type > | container_type
typedef value_type | ValueType
typedef key_type | KeyType
typedef container_type | ContainerType

## Public Member Functions

| BilinearInterpolation ()
| Constructors and destructor. More...
| BilinearInterpolation (BilinearInterpolation const &arg)
| Copy constructor. More...
BilinearInterpolation & | operator= (BilinearInterpolation const &arg)
| Assignment operator. More...
| ~BilinearInterpolation ()
| Destructor. More...
Interpolated data
ValueType | value (KeyType arg_pos_0, KeyType arg_pos_1) const
| Returns the interpolated value ("backward resampling") More...
void | addValue (KeyType arg_pos_0, KeyType arg_pos_1, ValueType arg_value)
| Performs bilinear resampling. The arg_value is split up and added to the data points around arg_pos. ("forward resampling") More...
Discrete (non-interpolated) data
ContainerType & | getData ()
| Returns the internal random access container storing the data. More...
ContainerType const & | getData () const
| Returns the internal random access container storing the data. More...
template<typename SourceContainer >
void | setData (SourceContainer const &data)
| Assigns data to the internal random access container storing the data. More...
bool | empty () const
| Returns `true` if getData() is empty. More...
Transformation
KeyType | key2index_0 (KeyType pos) const
| The transformation from "outside" to "inside" coordinates. More...
KeyType | index2key_0 (KeyType pos) const
| The transformation from "inside" to "outside" coordinates. More...
KeyType | key2index_1 (KeyType pos) const
| The transformation from "outside" to "inside" coordinates. More...
KeyType | index2key_1 (KeyType pos) const
| The transformation from "inside" to "outside" coordinates. More...
KeyType const & | getScale_0 () const
| Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data". More...
KeyType const & | getScale_1 () const
| Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data". More...
void | setScale_0 (KeyType const &scale)
| Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data". More...
void | setScale_1 (KeyType const &scale)
| Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data". More...
KeyType const & | getOffset_0 () const
| Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". More...
KeyType const & | getOffset_1 () const
| Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". More...
void | setOffset_0 (KeyType const &offset)
| Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". More...
void | setOffset_1 (KeyType const &offset)
| Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". More...
void | setMapping_0 (KeyType const &scale, KeyType const &inside_low, KeyType const &outside_low)
| Specifies the mapping from "outside" to "inside" coordinates by the following data: More...
void | setMapping_0 (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: More...
void | setMapping_1 (KeyType const &scale, KeyType const &inside_low, KeyType const &outside_low)
| Specifies the mapping from "outside" to "inside" coordinates by the following data: More...
void | setMapping_1 (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: More...
KeyType const & | getInsideReferencePoint_0 () const
| Accessor. See setMapping(). More...
KeyType const & | getInsideReferencePoint_1 () const
| Accessor. See setMapping(). More...
KeyType const & | getOutsideReferencePoint_0 () const
| Accessor. See setMapping(). More...
KeyType const & | getOutsideReferencePoint_1 () const
| Accessor. See setMapping(). More...
KeyType | supportMin_0 () const
| Lower boundary of the support, in "outside" coordinates. More...
KeyType | supportMin_1 () const
| Lower boundary of the support, in "outside" coordinates. More...
KeyType | supportMax_0 () const
| Upper boundary of the support, in "outside" coordinates. More...
KeyType | supportMax_1 () const
| Upper boundary of the support, in "outside" coordinates. More...

## Protected Attributes

KeyType | scale_0_
| Data members. More...
KeyType | offset_0_
KeyType | scale_1_
KeyType | offset_1_
KeyType | inside_0_
KeyType | outside_0_
KeyType | inside_1_
KeyType | outside_1_
ContainerType | data_

## Detailed Description

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

Provides access to bilinearly 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:

- using setScale() and setOffset(),
- using setMapping()

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

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

See also
  LinearInterpolation

## Member Typedef Documentation

## ◆ container_type

typedef Matrix<value_type> container_type

## ◆ ContainerType

typedef container_type ContainerType

## ◆ key_type

typedef Key key_type

## ◆ KeyType

typedef key_type KeyType

## ◆ value_type

typedef Value value_type

## ◆ ValueType

typedef value_type ValueType

## Constructor & Destructor Documentation

## ◆ BilinearInterpolation() [1/2]

BilinearInterpolation | ( |  | ) |

inline

Constructors and destructor.

Default constructor

## ◆ BilinearInterpolation() [2/2]

BilinearInterpolation | ( | BilinearInterpolation< Key, Value > const & | arg | ) |

inline

Copy constructor.

## ◆ ~BilinearInterpolation()

~BilinearInterpolation | ( |  | ) |

inline

Destructor.

## Member Function Documentation

## ◆ addValue()

void addValue | ( | KeyType | arg_pos_0,
|  | KeyType | arg_pos_1,
|  | ValueType | arg_value
| ) |  |

inline

Performs bilinear resampling. The arg_value is split up and added to the data points around arg_pos. ("forward resampling")

References Matrix< Value >::cols(), BilinearInterpolation< Key, Value >::data_, BilinearInterpolation< Key, Value >::key2index_0(), BilinearInterpolation< Key, Value >::key2index_1(), and Matrix< Value >::rows().

## ◆ empty()

bool empty | ( |  | ) | const

inline

Returns `true` if getData() is empty.

References BilinearInterpolation< Key, Value >::data_.

Referenced by BilinearInterpolation< Key, Value >::supportMin_0(), and BilinearInterpolation< Key, Value >::supportMin_1().

## ◆ getData() [1/2]

ContainerType& getData | ( |  | ) |

inline

Returns the internal random access container storing the data.

References BilinearInterpolation< Key, Value >::data_.

## ◆ getData() [2/2]

ContainerType const& getData | ( |  | ) | const

inline

Returns the internal random access container storing the data.

References BilinearInterpolation< Key, Value >::data_.

## ◆ getInsideReferencePoint_0()

KeyType const& getInsideReferencePoint_0 | ( |  | ) | const

inline

Accessor. See setMapping().

References BilinearInterpolation< Key, Value >::inside_0_.

## ◆ getInsideReferencePoint_1()

KeyType const& getInsideReferencePoint_1 | ( |  | ) | const

inline

Accessor. See setMapping().

References BilinearInterpolation< Key, Value >::inside_1_.

## ◆ getOffset_0()

KeyType const& getOffset_0 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::offset_0_.

## ◆ getOffset_1()

KeyType const& getOffset_1 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::offset_1_.

## ◆ getOutsideReferencePoint_0()

KeyType const& getOutsideReferencePoint_0 | ( |  | ) | const

inline

Accessor. See setMapping().

References BilinearInterpolation< Key, Value >::outside_0_.

## ◆ getOutsideReferencePoint_1()

KeyType const& getOutsideReferencePoint_1 | ( |  | ) | const

inline

Accessor. See setMapping().

References BilinearInterpolation< Key, Value >::outside_1_.

## ◆ getScale_0()

KeyType const& getScale_0 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::scale_0_.

## ◆ getScale_1()

KeyType const& getScale_1 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::scale_1_.

## ◆ index2key_0()

KeyType index2key_0 | ( | KeyType | pos | ) | const

inline

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

References BilinearInterpolation< Key, Value >::offset_0_, and BilinearInterpolation< Key, Value >::scale_0_.

Referenced by BilinearInterpolation< Key, Value >::supportMax_0(), and BilinearInterpolation< Key, Value >::supportMin_0().

## ◆ index2key_1()

KeyType index2key_1 | ( | KeyType | pos | ) | const

inline

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

References BilinearInterpolation< Key, Value >::offset_1_, and BilinearInterpolation< Key, Value >::scale_1_.

Referenced by BilinearInterpolation< Key, Value >::supportMax_1(), and BilinearInterpolation< Key, Value >::supportMin_1().

## ◆ key2index_0()

KeyType key2index_0 | ( | KeyType | pos | ) | const

inline

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

References BilinearInterpolation< Key, Value >::offset_0_, and BilinearInterpolation< Key, Value >::scale_0_.

Referenced by BilinearInterpolation< Key, Value >::addValue(), and BilinearInterpolation< Key, Value >::value().

## ◆ key2index_1()

KeyType key2index_1 | ( | KeyType | pos | ) | const

inline

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

References BilinearInterpolation< Key, Value >::offset_1_, and BilinearInterpolation< Key, Value >::scale_1_.

Referenced by BilinearInterpolation< Key, Value >::addValue(), and BilinearInterpolation< Key, Value >::value().

## ◆ operator=()

BilinearInterpolation& operator= | ( | BilinearInterpolation< Key, Value > const & | arg | ) |

inline

Assignment operator.

References BilinearInterpolation< Key, Value >::data_, BilinearInterpolation< Key, Value >::inside_0_, BilinearInterpolation< Key, Value >::inside_1_, BilinearInterpolation< Key, Value >::offset_0_, BilinearInterpolation< Key, Value >::offset_1_, BilinearInterpolation< Key, Value >::outside_0_, BilinearInterpolation< Key, Value >::outside_1_, BilinearInterpolation< Key, Value >::scale_0_, and BilinearInterpolation< Key, Value >::scale_1_.

## ◆ setData()

void setData | ( | SourceContainer const & | data | ) |

inline

Assigns data to the internal random access container storing the data.

SourceContainer must be assignable to ContainerType.

References BilinearInterpolation< Key, Value >::data_.

## ◆ setMapping_0() [1/2]

void setMapping_0 | ( | KeyType const & | scale,
|  | KeyType const & | inside_low,
|  | KeyType const & | outside_low
| ) |  |

inline

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 axis positions are mapped onto each other.

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.

References BilinearInterpolation< Key, Value >::inside_0_, BilinearInterpolation< Key, Value >::offset_0_, BilinearInterpolation< Key, Value >::outside_0_, and BilinearInterpolation< Key, Value >::scale_0_.

Referenced by BilinearInterpolation< Key, Value >::setMapping_0().

## ◆ setMapping_0() [2/2]

void setMapping_0 | ( | 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:

- `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.

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

References BilinearInterpolation< Key, Value >::setMapping_0().

## ◆ setMapping_1() [1/2]

void setMapping_1 | ( | KeyType const & | scale,
|  | KeyType const & | inside_low,
|  | KeyType const & | outside_low
| ) |  |

inline

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 axis positions are mapped onto each other.

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.

References BilinearInterpolation< Key, Value >::inside_1_, BilinearInterpolation< Key, Value >::offset_1_, BilinearInterpolation< Key, Value >::outside_1_, and BilinearInterpolation< Key, Value >::scale_1_.

Referenced by BilinearInterpolation< Key, Value >::setMapping_1().

## ◆ setMapping_1() [2/2]

void setMapping_1 | ( | 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:

- `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.

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

References BilinearInterpolation< Key, Value >::setMapping_1().

## ◆ setOffset_0()

void setOffset_0 | ( | KeyType const & | offset | ) |

inline

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

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

References BilinearInterpolation< Key, Value >::offset_0_.

## ◆ setOffset_1()

void setOffset_1 | ( | KeyType const & | offset | ) |

inline

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

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

References BilinearInterpolation< Key, Value >::offset_1_.

## ◆ setScale_0()

void setScale_0 | ( | KeyType const & | scale | ) |

inline

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

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

References BilinearInterpolation< Key, Value >::scale_0_.

## ◆ setScale_1()

void setScale_1 | ( | KeyType const & | scale | ) |

inline

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

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

References BilinearInterpolation< Key, Value >::scale_1_.

## ◆ supportMax_0()

KeyType supportMax_0 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::data_, BilinearInterpolation< Key, Value >::index2key_0(), and Matrix< Value >::rows().

## ◆ supportMax_1()

KeyType supportMax_1 | ( |  | ) | const

inline

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

References Matrix< Value >::cols(), BilinearInterpolation< Key, Value >::data_, and BilinearInterpolation< Key, Value >::index2key_1().

## ◆ supportMin_0()

KeyType supportMin_0 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::empty(), and BilinearInterpolation< Key, Value >::index2key_0().

## ◆ supportMin_1()

KeyType supportMin_1 | ( |  | ) | const

inline

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

References BilinearInterpolation< Key, Value >::empty(), and BilinearInterpolation< Key, Value >::index2key_1().

## ◆ value()

ValueType value | ( | KeyType | arg_pos_0,
|  | KeyType | arg_pos_1
| ) |  | const

inline

Returns the interpolated value ("backward resampling")

References Matrix< Value >::cols(), BilinearInterpolation< Key, Value >::data_, BilinearInterpolation< Key, Value >::key2index_0(), BilinearInterpolation< Key, Value >::key2index_1(), and Matrix< Value >::rows().

## Member Data Documentation

## ◆ data_

ContainerType data_

protected

Referenced by BilinearInterpolation< Key, Value >::addValue(), BilinearInterpolation< Key, Value >::empty(), BilinearInterpolation< Key, Value >::getData(), BilinearInterpolation< Key, Value >::operator=(), BilinearInterpolation< Key, Value >::setData(), BilinearInterpolation< Key, Value >::supportMax_0(), BilinearInterpolation< Key, Value >::supportMax_1(), and BilinearInterpolation< Key, Value >::value().

## ◆ inside_0_

KeyType inside_0_

protected

Referenced by BilinearInterpolation< Key, Value >::getInsideReferencePoint_0(), BilinearInterpolation< Key, Value >::operator=(), and BilinearInterpolation< Key, Value >::setMapping_0().

## ◆ inside_1_

KeyType inside_1_

protected

Referenced by BilinearInterpolation< Key, Value >::getInsideReferencePoint_1(), BilinearInterpolation< Key, Value >::operator=(), and BilinearInterpolation< Key, Value >::setMapping_1().

## ◆ offset_0_

KeyType offset_0_

protected

Referenced by BilinearInterpolation< Key, Value >::getOffset_0(), BilinearInterpolation< Key, Value >::index2key_0(), BilinearInterpolation< Key, Value >::key2index_0(), BilinearInterpolation< Key, Value >::operator=(), BilinearInterpolation< Key, Value >::setMapping_0(), and BilinearInterpolation< Key, Value >::setOffset_0().

## ◆ offset_1_

KeyType offset_1_

protected

Referenced by BilinearInterpolation< Key, Value >::getOffset_1(), BilinearInterpolation< Key, Value >::index2key_1(), BilinearInterpolation< Key, Value >::key2index_1(), BilinearInterpolation< Key, Value >::operator=(), BilinearInterpolation< Key, Value >::setMapping_1(), and BilinearInterpolation< Key, Value >::setOffset_1().

## ◆ outside_0_

KeyType outside_0_

protected

Referenced by BilinearInterpolation< Key, Value >::getOutsideReferencePoint_0(), BilinearInterpolation< Key, Value >::operator=(), and BilinearInterpolation< Key, Value >::setMapping_0().

## ◆ outside_1_

KeyType outside_1_

protected

Referenced by BilinearInterpolation< Key, Value >::getOutsideReferencePoint_1(), BilinearInterpolation< Key, Value >::operator=(), and BilinearInterpolation< Key, Value >::setMapping_1().

## ◆ scale_0_

KeyType scale_0_

protected

Data members.

Referenced by BilinearInterpolation< Key, Value >::getScale_0(), BilinearInterpolation< Key, Value >::index2key_0(), BilinearInterpolation< Key, Value >::key2index_0(), BilinearInterpolation< Key, Value >::operator=(), BilinearInterpolation< Key, Value >::setMapping_0(), and BilinearInterpolation< Key, Value >::setScale_0().

## ◆ scale_1_

KeyType scale_1_

protected

Referenced by BilinearInterpolation< Key, Value >::getScale_1(), BilinearInterpolation< Key, Value >::index2key_1(), BilinearInterpolation< Key, Value >::key2index_1(), BilinearInterpolation< Key, Value >::operator=(), BilinearInterpolation< Key, Value >::setMapping_1(), and BilinearInterpolation< Key, Value >::setScale_1().