votca 2024-dev
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
votca::tools::Spline Class Referenceabstract

Spline Class. More...

#include <spline.h>

Inheritance diagram for votca::tools::Spline:
Inheritance graph
[legend]

Public Types

enum  eBoundary { splineNormal = 0 , splinePeriodic = 1 , splineDerivativeZero = 2 }
 enum for type of boundary condition More...
 

Public Member Functions

 Spline ()=default
 
virtual ~Spline ()=default
 
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 Calculate().
 
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 Calculate().
 
virtual double Calculate (double x)=0
 Calculate spline function value for a given x value on the spline created by Interpolate() or Fit()
 
virtual double CalculateDerivative (double x)=0
 Calculate y value for a given x value on the derivative of the spline created by function Interpolate or Fit.
 
void setBC (eBoundary bc)
 Set the boundary type of the spline.
 
void setBCInt (Index bc)
 Set the boundary type of the spline.
 
double getGridPoint (int i)
 Get the grid point of certain index.
 
Eigen::VectorXd Calculate (const Eigen::VectorXd &x)
 Calculate spline function values for given x values on the spline created by Interpolate() or Fit()
 
Eigen::VectorXd CalculateDerivative (const Eigen::VectorXd &x)
 Calculate y values for given x values on the derivative of the spline created by function Interpolate or Fit.
 
void Print (std::ostream &out, double interval)
 Print spline values (using Calculate()) on output "out" on the entire grid in steps of "interval".
 
Index getInterval (double r)
 Determine the index of the interval containing value r.
 
Index GenerateGrid (double min, double max, double h)
 Generate the grid for fitting from "min" to "max" in steps of "h".
 
Eigen::VectorXd & getX ()
 Get the grid array x.
 
const Eigen::VectorXd & getX () const
 

Protected Attributes

eBoundary boundaries_ = eBoundary::splineNormal
 Get the spline data f_.
 
Eigen::VectorXd r_
 

Detailed Description

Spline Class.

class supports spline interpolation and fit of data the cubic spline class, akima spline class and linear spline class are inherited from this one

Definition at line 36 of file spline.h.

Member Enumeration Documentation

◆ eBoundary

enum for type of boundary condition

Enumerator
splineNormal 

normal boundary conditions: \(f_0=f_N=0\)

splinePeriodic 

periodic boundary conditions: \(f_0=f_N\)

splineDerivativeZero 

derivatives and end-points are zero.

Definition at line 73 of file spline.h.

Constructor & Destructor Documentation

◆ Spline()

votca::tools::Spline::Spline ( )
default

◆ ~Spline()

virtual votca::tools::Spline::~Spline ( )
virtualdefault

Member Function Documentation

◆ Calculate() [1/2]

Eigen::VectorXd votca::tools::Spline::Calculate ( const Eigen::VectorXd &  x)

Calculate spline function values for given x values on the spline created by Interpolate() or Fit()

Parameters
xvector of data values
Returns
vector of y value

Definition at line 40 of file spline.cc.

◆ Calculate() [2/2]

virtual double votca::tools::Spline::Calculate ( double  x)
pure virtual

Calculate spline function value for a given x value on the spline created by Interpolate() or Fit()

Parameters
xdata value
Returns
y value

Implemented in votca::tools::AkimaSpline, votca::tools::CubicSpline, votca::tools::LinSpline, votca::tools::AkimaSpline, votca::tools::CubicSpline, and votca::tools::LinSpline.

◆ CalculateDerivative() [1/2]

Eigen::VectorXd votca::tools::Spline::CalculateDerivative ( const Eigen::VectorXd &  x)

Calculate y values for given x values on the derivative of the spline created by function Interpolate or Fit.

Parameters
xvector of data values
Returns
vector of y value

Definition at line 48 of file spline.cc.

◆ CalculateDerivative() [2/2]

virtual double votca::tools::Spline::CalculateDerivative ( double  x)
pure virtual

Calculate y value for a given x value on the derivative of the spline created by function Interpolate or Fit.

Parameters
xdata value
Returns
y value of derivative

Implemented in votca::tools::AkimaSpline, votca::tools::CubicSpline, votca::tools::LinSpline, votca::tools::AkimaSpline, votca::tools::CubicSpline, and votca::tools::LinSpline.

◆ Fit()

virtual void votca::tools::Spline::Fit ( const Eigen::VectorXd &  x,
const Eigen::VectorXd &  y 
)
pure virtual

Fit spline through noisy (x,y) values. Points on resulting fitted spline can be obtained via Calculate().

Parameters
xvalues of data to be fitted
yvalues of data to be fitted both vectors must be of same size

Implemented in votca::tools::AkimaSpline, votca::tools::CubicSpline, and votca::tools::LinSpline.

◆ GenerateGrid()

Index votca::tools::Spline::GenerateGrid ( double  min,
double  max,
double  h 
)

Generate the grid for fitting from "min" to "max" in steps of "h".

Parameters
minleft interval border
maxright interval border
hstep
Returns
number of grid values in the interval

Definition at line 26 of file spline.cc.

◆ getGridPoint()

double votca::tools::Spline::getGridPoint ( int  i)

Get the grid point of certain index.

Parameters
iindex of grid point
Returns
grid value

Definition at line 78 of file spline.cc.

◆ getInterval()

Index votca::tools::Spline::getInterval ( double  r)

Determine the index of the interval containing value r.

Parameters
r
Returns
interval index

Definition at line 62 of file spline.cc.

◆ getX() [1/2]

Eigen::VectorXd & votca::tools::Spline::getX ( )
inline

Get the grid array x.

Returns
pointer to the corresponding array

Definition at line 154 of file spline.h.

◆ getX() [2/2]

const Eigen::VectorXd & votca::tools::Spline::getX ( ) const
inline

Definition at line 155 of file spline.h.

◆ Interpolate()

virtual void votca::tools::Spline::Interpolate ( const Eigen::VectorXd &  x,
const Eigen::VectorXd &  y 
)
pure virtual

Calculate interpolating spline for given (x,y) values. Points on resulting spline can be obtained via Calculate().

Parameters
xvalues of data to be interpolated
yvalues of data to be interpolated both vectors must be of same size

Implemented in votca::tools::AkimaSpline, votca::tools::CubicSpline, and votca::tools::LinSpline.

◆ Print()

void votca::tools::Spline::Print ( std::ostream &  out,
double  interval 
)

Print spline values (using Calculate()) on output "out" on the entire grid in steps of "interval".

Parameters
outoutput
intervalsize of "interval"

Definition at line 56 of file spline.cc.

◆ setBC()

void votca::tools::Spline::setBC ( eBoundary  bc)
inline

Set the boundary type of the spline.

Parameters
bcof type eBoundary

Definition at line 83 of file spline.h.

◆ setBCInt()

void votca::tools::Spline::setBCInt ( Index  bc)
inline

Set the boundary type of the spline.

Parameters
bcof type Index

Definition at line 89 of file spline.h.

Member Data Documentation

◆ boundaries_

eBoundary votca::tools::Spline::boundaries_ = eBoundary::splineNormal
protected

Get the spline data f_.

Returns
reference to the corresponding array

Get second derivatives (cubic splines)

Returns
reference to the corresponding array

Definition at line 171 of file spline.h.

◆ r_

Eigen::VectorXd votca::tools::Spline::r_
protected

Definition at line 173 of file spline.h.


The documentation for this class was generated from the following files: