votca 2024.2-dev
Loading...
Searching...
No Matches
spline.h
Go to the documentation of this file.
1/*
2 * Copyright 2010-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_TOOLS_SPLINE_H
19#define VOTCA_TOOLS_SPLINE_H
20
21// Local VOTCA includes
22#include "eigen.h"
23#include "types.h"
24
25namespace votca {
26namespace tools {
27
36class Spline {
37 public:
38 Spline() = default;
39
40 virtual ~Spline() = default;
41
48 virtual void Interpolate(const Eigen::VectorXd &x,
49 const Eigen::VectorXd &y) = 0;
50
57 virtual void Fit(const Eigen::VectorXd &x, const Eigen::VectorXd &y) = 0;
58
63 virtual double Calculate(double x) = 0;
64
70 virtual double CalculateDerivative(double x) = 0;
71
78
83 void setBC(eBoundary bc) { boundaries_ = bc; }
84
89 void setBCInt(Index bc) {
90 switch (bc) {
91 case 0:
93 break;
94 case 1:
96 break;
97 case 2:
99 break;
100 }
101 }
102
108 double getGridPoint(int i);
109
116 Eigen::VectorXd Calculate(const Eigen::VectorXd &x);
117
124 Eigen::VectorXd CalculateDerivative(const Eigen::VectorXd &x);
125
132 void Print(std::ostream &out, double interval);
133
139 Index getInterval(double r);
140
148 Index GenerateGrid(double min, double max, double h);
149
154 Eigen::VectorXd &getX() { return r_; }
155 const Eigen::VectorXd &getX() const { return r_; }
160 // Eigen::VectorXd &getSplineF() { return f_; }
161 // const Eigen::VectorXd &getSplineF() const { return f_; }
162
167 // Eigen::VectorXd &getSplineF2() { return f2_; }
168 // const Eigen::VectorXd &getSplineF2() const { return f_; }
169
170 protected:
172 // the grid points
173 Eigen::VectorXd r_;
174};
175
176} // namespace tools
177} // namespace votca
178
179#endif // VOTCA_TOOLS_SPLINE_H
Spline Class.
Definition spline.h:36
Eigen::VectorXd & getX()
Get the grid array x.
Definition spline.h:154
void Print(std::ostream &out, double interval)
Print spline values (using Calculate()) on output "out" on the entire grid in steps of "interval".
Definition spline.cc:56
virtual double CalculateDerivative(double x)=0
Calculate y value for a given x value on the derivative of the spline created by function Interpolate...
void setBC(eBoundary bc)
Set the boundary type of the spline.
Definition spline.h:83
virtual void Interpolate(const Eigen::VectorXd &x, const Eigen::VectorXd &y)=0
Calculate interpolating spline for given (x,y) values. Points on resulting spline can be obtained via...
virtual double Calculate(double x)=0
Calculate spline function value for a given x value on the spline created by Interpolate() or Fit()
Eigen::VectorXd r_
Definition spline.h:173
virtual ~Spline()=default
eBoundary boundaries_
Get the spline data f_.
Definition spline.h:171
Index getInterval(double r)
Determine the index of the interval containing value r.
Definition spline.cc:62
void setBCInt(Index bc)
Set the boundary type of the spline.
Definition spline.h:89
eBoundary
enum for type of boundary condition
Definition spline.h:73
@ splineDerivativeZero
derivatives and end-points are zero.
Definition spline.h:76
@ splinePeriodic
periodic boundary conditions:
Definition spline.h:75
@ splineNormal
normal boundary conditions:
Definition spline.h:74
const Eigen::VectorXd & getX() const
Definition spline.h:155
double getGridPoint(int i)
Get the grid point of certain index.
Definition spline.cc:78
virtual void Fit(const Eigen::VectorXd &x, const Eigen::VectorXd &y)=0
Fit spline through noisy (x,y) values. Points on resulting fitted spline can be obtained via Calculat...
Index GenerateGrid(double min, double max, double h)
Generate the grid for fitting from "min" to "max" in steps of "h".
Definition spline.cc:26
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26