ProteoWizard
CubicHermiteSpline.hpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Austin Keller <atkeller .@. uw.edu>
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 
20 #ifndef _CUBICHERMITESPLINE_HPP
21 #define _CUBICHERMITESPLINE_HPP
22 
23 #include "IInterpolation.hpp"
24 #include <CSpline.h>
25 #include <Eigen>
26 #include <vector>
27 
28 namespace pwiz
29 {
30 namespace analysis
31 {
32  /// An implementation of the IInterpolation interface that acts as a wrapper for a cSpline.
34  {
35  public:
36 
37  /// Constructs a CubicHermiteSpline using standard vectors
38  /// @param points The independent values as a monotonically increasing series
39  /// @param values The dependent values
40  /// \pre points must be sorted in order of increasing value with no duplicates
41  /// \pre points and values must be of the same size
42  CubicHermiteSpline(const std::vector<double>& points, const std::vector<double>& values);
43 
44  /// Constructs a CubicHermiteSpline using Eigen vectors
45  /// @param points The independent values as a monotonically increasing series
46  /// @param values The dependent values
47  /// \pre points must be sorted in order of increasing value with no duplicates
48  /// \pre points and values must be of the same size
49  CubicHermiteSpline(const Eigen::VectorXd& points, const Eigen::VectorXd& values);
50 
52 
53  /// \name IInterpolation interface
54  ///@{
55 
56  bool IsDifferentiable() override;
57  bool IsIntegrable() override;
58  double Differentiate(double x) override;
59  double Integrate(double a, double b) override;
60  double Interpolate(double x) override;
61  ///@}
62  private:
63 
64  /// Checks for errors and throws exception if cSpline initialization resulted in an error
65  void CheckForError() const;
66 
67  /// The class containing the algorithm for constructing splines and retrieving interpolated values
68  cSpline* cSpline_;
69  };
70 } // namespace analysis
71 } // namespace pwiz
72 #endif // _CUBICHERMITESPLINE_HPP
pwiz::analysis::CubicHermiteSpline::CubicHermiteSpline
CubicHermiteSpline(const std::vector< double > &points, const std::vector< double > &values)
Constructs a CubicHermiteSpline using standard vectors.
pwiz::analysis::CubicHermiteSpline::CheckForError
void CheckForError() const
Checks for errors and throws exception if cSpline initialization resulted in an error.
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::analysis::CubicHermiteSpline
An implementation of the IInterpolation interface that acts as a wrapper for a cSpline.
Definition: CubicHermiteSpline.hpp:34
pwiz::analysis::CubicHermiteSpline::cSpline_
cSpline * cSpline_
The class containing the algorithm for constructing splines and retrieving interpolated values.
Definition: CubicHermiteSpline.hpp:68
pwiz::analysis::CubicHermiteSpline::~CubicHermiteSpline
virtual ~CubicHermiteSpline()
pwiz::analysis::CubicHermiteSpline::CubicHermiteSpline
CubicHermiteSpline(const Eigen::VectorXd &points, const Eigen::VectorXd &values)
Constructs a CubicHermiteSpline using Eigen vectors.
IInterpolation.hpp
x
KernelTraitsBase< Kernel >::space_type::abscissa_type x
Definition: MatchedFilter.hpp:142
pwiz::analysis::CubicHermiteSpline::IsDifferentiable
bool IsDifferentiable() override
Indicates whether the algorithm can provide an interpolated derivative.
pwiz::analysis::CubicHermiteSpline::Differentiate
double Differentiate(double x) override
Derivative at the point x.
pwiz::analysis::CubicHermiteSpline::Interpolate
double Interpolate(double x) override
Interpolate at point x.
pwiz::analysis::CubicHermiteSpline::Integrate
double Integrate(double a, double b) override
Definite integral between points a and b over function f.
pwiz::analysis::CubicHermiteSpline::IsIntegrable
bool IsIntegrable() override
Indicates whether the algorithm can provide an interpolated integral.
IInterpolation
Interface for interpolating between points in a discrete data set.
Definition: IInterpolation.hpp:25