OpenMS
Loading...
Searching...
No Matches
CubicSpline2d.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Lars Nilse $
6// $Authors: Lars Nilse $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/OpenMSConfig.h>
12
13#include <vector>
14#include <map>
15
16namespace OpenMS
17{
36 class OPENMS_DLLAPI CubicSpline2d
37 {
38
39 std::vector<double> a_;
40 std::vector<double> b_;
41 std::vector<double> c_;
42 std::vector<double> d_;
43 std::vector<double> x_;
44
45public:
46
59 CubicSpline2d(const std::vector<double>& x, const std::vector<double>& y);
60
72 CubicSpline2d(const std::map<double, double>& m);
73
83 double eval(double x) const;
84
96 double derivative(double x) const;
97
114 double derivatives(double x, unsigned order) const;
115
116private:
117
128 void init_(const std::vector<double>& x, const std::vector<double>& y);
129
130 };
131
132}
133
Natural cubic-spline interpolation of a 2D data set.
Definition CubicSpline2d.h:37
std::vector< double > c_
Per-segment quadratic coefficient (degree 2); contains one extra trailing zero from the natural bound...
Definition CubicSpline2d.h:41
double derivative(double x) const
First derivative of the spline at x.
double eval(double x) const
Evaluate the spline at x.
std::vector< double > a_
Per-segment constant coefficient (degree 0); same value as the y at the segment's left knot.
Definition CubicSpline2d.h:39
std::vector< double > b_
Per-segment linear coefficient (degree 1).
Definition CubicSpline2d.h:40
CubicSpline2d(const std::map< double, double > &m)
Build the spline from a map of (x, y) knots.
void init_(const std::vector< double > &x, const std::vector< double > &y)
Initialise the spline coefficients from the supplied knots.
std::vector< double > x_
Sorted knot abscissae (length = number of segments + 1).
Definition CubicSpline2d.h:43
std::vector< double > d_
Per-segment cubic coefficient (degree 3).
Definition CubicSpline2d.h:42
CubicSpline2d(const std::vector< double > &x, const std::vector< double > &y)
Build the spline from parallel x / y vectors.
double derivatives(double x, unsigned order) const
Derivative of the spline at x.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19