35 #ifndef OPENMS_MATH_MISC_BILINEARINTERPOLATION_H 
   36 #define OPENMS_MATH_MISC_BILINEARINTERPOLATION_H 
   72     template <
typename Key = 
double, 
typename Value = Key>
 
  182                 return data_(0, 0) * (1. + pos_0) * (1. + pos_1);
 
  187             if (lower_1 >= size_1 - 1)
 
  189               if (lower_1 != size_1 - 1)
 
  195                 return data_(0, lower_1) * (1. + pos_0) * (size_1 - pos_1);
 
  201             KeyType 
const factor_1_complement = 
KeyType(1.) - factor_1;
 
  203                      data_(0, lower_1 + 1) * factor_1 +
 
  204                      data_(0, lower_1) * factor_1_complement
 
  210         if (lower_0 >= size_0 - 1)
 
  212           if (lower_0 != size_0 - 1)
 
  226                 return data_(lower_0, 0) * (size_0 - pos_0) * (1. + pos_1);
 
  231             if (lower_1 >= size_1 - 1)
 
  233               if (lower_1 != size_1 - 1)
 
  239                 return data_(lower_0, lower_1) * (size_0 - pos_0) * (size_1 - pos_1);
 
  245             KeyType 
const factor_1_complement = 
KeyType(1.) - factor_1;
 
  247                      data_(lower_0, lower_1 + 1) * factor_1 +
 
  248                      data_(lower_0, lower_1) * factor_1_complement
 
  257           KeyType 
const factor_0_complement = 
KeyType(1.) - factor_0;
 
  269                        data_(lower_0 + 1, 0) * factor_0
 
  271                        data_(lower_0, 0) * factor_0_complement
 
  278           if (lower_1 >= size_1 - 1)
 
  280             if (lower_1 != size_1 - 1)
 
  287                        data_(lower_0 + 1, lower_1) * factor_0
 
  289                        data_(lower_0, lower_1) * factor_0_complement
 
  294           KeyType 
const factor_1 = pos_1 - 
KeyType(lower_1);
 
  295           KeyType 
const factor_1_complement = 
KeyType(1.) - factor_1;
 
  299                    data_(lower_0 + 1, lower_1 + 1) * factor_0
 
  301                    data_(lower_0, lower_1 + 1) * factor_0_complement
 
  306                    data_(lower_0 + 1, lower_1) * factor_0
 
  308                    data_(lower_0, lower_1) * factor_0_complement
 
  310                  * factor_1_complement;
 
  325         KeyType const frac_0 = std::modf(pos_0, &lower_0_key);
 
  326         DiffType 
const lower_0 = DiffType(lower_0_key);
 
  339             KeyType const frac_1 = std::modf(pos_1, &lower_1_key);
 
  340             DiffType 
const lower_1 = DiffType(lower_1_key);
 
  351                 data_(0, 0) += arg_value * (1 + frac_0) * (1 + frac_1);
 
  357               DiffType 
const back_1 = 
data_.
cols() - 1;
 
  359               if (lower_1 >= back_1)
 
  361                 if (lower_1 != back_1)
 
  367                   data_(0, lower_1) += arg_value * (1 + frac_0) * (1 - frac_1);
 
  375                 data_(0, lower_1 + 1) += tmp_prod * frac_1;
 
  376                 data_(0, lower_1) += tmp_prod * (1. - frac_1);
 
  384           DiffType 
const back_0 = 
data_.
rows() - 1;
 
  385           if (lower_0 >= back_0)
 
  387             if (lower_0 != back_0)
 
  399               KeyType const frac_1 = std::modf(pos_1, &lower_1_key);
 
  400               DiffType 
const lower_1 = DiffType(lower_1_key);
 
  411                   data_(lower_0, 0) += tmp_prod * (1 + frac_1);
 
  417                 DiffType 
const back_1 = 
data_.
cols() - 1;
 
  419                 if (lower_1 >= back_1)
 
  421                   if (lower_1 != back_1)
 
  427                     data_(lower_0, lower_1) += tmp_prod * (1 - frac_1);
 
  434                   data_(lower_0, lower_1 + 1) += tmp_prod * frac_1;
 
  435                   data_(lower_0, lower_1) += tmp_prod * (1 - frac_1);
 
  449             KeyType const frac_1 = std::modf(pos_1, &lower_1_key);
 
  450             DiffType 
const lower_1 = DiffType(lower_1_key);
 
  462                 data_(lower_0 + 1, 0) += tmp_prod * frac_0;
 
  463                 data_(lower_0, 0) += tmp_prod * (1 - frac_0);
 
  469               DiffType 
const back_1 = 
data_.
cols() - 1;
 
  471               if (lower_1 >= back_1)
 
  473                 if (lower_1 != back_1)
 
  480                   data_(lower_0 + 1, lower_1) += tmp_prod * frac_0;
 
  481                   data_(lower_0, lower_1) += tmp_prod * (1 - frac_0);
 
  491                 data_(lower_0 + 1, lower_1 + 1) += tmp_prod * frac_1;
 
  492                 data_(lower_0 + 1, lower_1) += tmp_prod * (1 - frac_1);
 
  493                 tmp_prod = 
KeyType(arg_value * (1 - frac_0));
 
  494                 data_(lower_0, lower_1 + 1) += tmp_prod * frac_1;
 
  495                 data_(lower_0, lower_1) += tmp_prod * (1 - frac_1);
 
  527       template <
typename SourceContainer>
 
  536         return data_.empty();
 
  676         offset_0_ = outside_low - scale * inside_low;
 
  689         if (inside_high != inside_low)
 
  691           setMapping_0((outside_high - outside_low) / (inside_high - inside_low),
 
  692                        inside_low, outside_low);
 
  719         offset_1_ = outside_low - scale * inside_low;
 
  732         if (inside_high != inside_low)
 
  734           setMapping_1((outside_high - outside_low) / (inside_high - inside_low),
 
  735                        inside_low, outside_low);
 
  814 #endif // OPENMS_MATH_MISC_BILINEARINTERPOLATION_H 
container_type ContainerType
Definition: BilinearInterpolation.h:87
KeyType scale_1_
Definition: BilinearInterpolation.h:800
ContainerType data_
Definition: BilinearInterpolation.h:806
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: ...
Definition: BilinearInterpolation.h:729
KeyType offset_0_
Definition: BilinearInterpolation.h:799
KeyType offset_1_
Definition: BilinearInterpolation.h:801
void setData(SourceContainer const &data)
Assigns data to the internal random access container storing the data. 
Definition: BilinearInterpolation.h:528
KeyType const & getScale_1() const 
Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data"...
Definition: BilinearInterpolation.h:599
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: ...
Definition: BilinearInterpolation.h:714
void setOffset_0(KeyType const &offset)
Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". 
Definition: BilinearInterpolation.h:642
key_type KeyType
Definition: BilinearInterpolation.h:86
void setScale_0(KeyType const &scale)
Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data"...
Definition: BilinearInterpolation.h:609
Base::difference_type difference_type
Definition: Matrix.h:91
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference. 
Definition: Types.h:151
KeyType inside_1_
Definition: BilinearInterpolation.h:804
KeyType outside_1_
Definition: BilinearInterpolation.h:805
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: ...
Definition: BilinearInterpolation.h:686
BilinearInterpolation()
Constructors and destructor. 
Definition: BilinearInterpolation.h:97
KeyType const & getOutsideReferencePoint_0() const 
Accessor. See setMapping(). 
Definition: BilinearInterpolation.h:757
void setScale_1(KeyType const &scale)
Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data"...
Definition: BilinearInterpolation.h:619
KeyType supportMin_1() const 
Lower boundary of the support, in "outside" coordinates. 
Definition: BilinearInterpolation.h:775
void setOffset_1(KeyType const &offset)
Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". 
Definition: BilinearInterpolation.h:653
Provides access to bilinearly interpolated values (and derivatives) from discrete data points...
Definition: BilinearInterpolation.h:73
KeyType const & getOutsideReferencePoint_1() const 
Accessor. See setMapping(). 
Definition: BilinearInterpolation.h:763
KeyType key2index_0(KeyType pos) const 
The transformation from "outside" to "inside" coordinates. 
Definition: BilinearInterpolation.h:547
KeyType const & getScale_0() const 
Accessor. "Scale" is the difference (in "outside" units) between consecutive entries in "Data"...
Definition: BilinearInterpolation.h:593
BilinearInterpolation(BilinearInterpolation const &arg)
Copy constructor. 
Definition: BilinearInterpolation.h:110
BilinearInterpolation & operator=(BilinearInterpolation const &arg)
Assignment operator. 
Definition: BilinearInterpolation.h:123
Matrix< value_type > container_type
Definition: BilinearInterpolation.h:83
KeyType outside_0_
Definition: BilinearInterpolation.h:803
ContainerType & getData()
Returns the internal random access container storing the data. 
Definition: BilinearInterpolation.h:511
SizeType rows() const 
Number of rows. 
Definition: Matrix.h:262
KeyType supportMax_1() const 
Upper boundary of the support, in "outside" coordinates. 
Definition: BilinearInterpolation.h:787
SizeType cols() const 
Number of columns. 
Definition: Matrix.h:268
KeyType const & getInsideReferencePoint_1() const 
Accessor. See setMapping(). 
Definition: BilinearInterpolation.h:751
KeyType supportMin_0() const 
Lower boundary of the support, in "outside" coordinates. 
Definition: BilinearInterpolation.h:769
KeyType scale_0_
Data members. 
Definition: BilinearInterpolation.h:798
bool empty() const 
Returns true if getData() is empty. 
Definition: BilinearInterpolation.h:534
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...
Definition: BilinearInterpolation.h:317
ValueType value(KeyType arg_pos_0, KeyType arg_pos_1) const 
Returns the interpolated value ("backward resampling") 
Definition: BilinearInterpolation.h:152
KeyType index2key_0(KeyType pos) const 
The transformation from "inside" to "outside" coordinates. 
Definition: BilinearInterpolation.h:562
KeyType supportMax_0() const 
Upper boundary of the support, in "outside" coordinates. 
Definition: BilinearInterpolation.h:781
KeyType index2key_1(KeyType pos) const 
The transformation from "inside" to "outside" coordinates. 
Definition: BilinearInterpolation.h:585
ContainerType const & getData() const 
Returns the internal random access container storing the data. 
Definition: BilinearInterpolation.h:517
Value value_type
Definition: BilinearInterpolation.h:80
KeyType const & getInsideReferencePoint_0() const 
Accessor. See setMapping(). 
Definition: BilinearInterpolation.h:745
Key key_type
Definition: BilinearInterpolation.h:82
value_type ValueType
Definition: BilinearInterpolation.h:85
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: ...
Definition: BilinearInterpolation.h:671
KeyType const & getOffset_1() const 
Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". 
Definition: BilinearInterpolation.h:631
KeyType key2index_1(KeyType pos) const 
The transformation from "outside" to "inside" coordinates. 
Definition: BilinearInterpolation.h:570
KeyType inside_0_
Definition: BilinearInterpolation.h:802
~BilinearInterpolation()
Destructor. 
Definition: BilinearInterpolation.h:141
KeyType const & getOffset_0() const 
Accessor. "Offset" is the point (in "outside" units) which corresponds to "Data(0,0)". 
Definition: BilinearInterpolation.h:625
A two-dimensional matrix. Similar to std::vector, but uses a binary operator(,) for element access...
Definition: Matrix.h:79