Public Types | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
o2scl::interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t > Class Template Reference

Bilinear or bicubic two-dimensional interpolation. More...

#include <interp2_direct.h>

Inheritance diagram for o2scl::interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t >:
o2scl::interp2_base< vec_t, mat_t >

Public Types

typedef boost::numeric::ublas::matrix< double > ubmatrix
 
typedef boost::numeric::ublas::matrix_column< ubmatrixubmatrix_col
 

Public Member Functions

void set_data (size_t n_x, size_t n_y, vec_t &x_grid, vec_t &y_grid, mat_t &data, size_t interp_type=itp_cspline)
 Initialize the data for the 2-dimensional interpolation.
 
virtual double eval (double x, double y) const
 Perform the 2-d interpolation.
 
virtual double deriv_x (double x, double y) const
 Compute the partial derivative in the x-direction.
 
virtual double deriv_xx (double x, double y) const
 Compute the partial second derivative in the x-direction.
 
virtual double deriv_y (double x, double y) const
 Compute the partial derivative in the y-direction.
 
virtual double deriv_yy (double x, double y) const
 Compute the partial second derivative in the y-direction.
 
virtual double deriv_xy (double x, double y) const
 Compute the mixed partial derivative $ \frac{\partial^2 f}{\partial x \partial y} $.
 
virtual double integ_x (double x0, double x1, double y) const
 Compute the integral in the x-direction between x=x0 and x=x1.
 
virtual double integ_y (double x, double y0, double y1) const
 Compute the integral in the y-direction between y=y0 and y=y1.
 
virtual double eval_gen (int ix, int iy, double x0, double x1, double y0, double y1) const
 Compute a general interpolation result. More...
 
- Public Member Functions inherited from o2scl::interp2_base< vec_t, mat_t >
virtual double operator() (double x, double y) const
 Perform the 2-d interpolation.
 

Protected Attributes

bool data_set
 True if the data has been specified by the user.
 
size_t itype
 Interpolation type.
 
ubmatrix zx
 Partial derivative with respect to x.
 
ubmatrix zy
 Partial derivative with respect to y.
 
ubmatrix zxy
 Mixed partial derivative.
 
search_vec< vec_t > svx
 Searching object for x-direction.
 
search_vec< vec_t > svy
 Searching object for y-direction.
 
- Protected Attributes inherited from o2scl::interp2_base< vec_t, mat_t >
size_t nx
 The number of x grid points.
 
size_t ny
 The number of y grid points.
 
vec_t * xfun
 The x grid.
 
vec_t * yfun
 The y grid.
 
mat_t * datap
 The data.
 

Private Member Functions

 interp2_direct (const interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t > &)
 
interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t > & operator= (const interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t > &)
 

Detailed Description

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class mat_row_t = boost::numeric::ublas::matrix_row<mat_t>, class mat_column_t = boost::numeric::ublas::matrix_column<mat_t>>
class o2scl::interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t >

This class implements two-dimensional interpolation. First and second derivatives along both x- and y-directions can be computed. This class is likely a bit faster than o2scl::interp2_seq but less flexible.

The convention used by this class is that the first (row) index of the matrix enumerates the x coordinate and that the second (column) index enumerates the y coordinate. See the discussion in the User's guide in the section called Rows and columns vs. x and y.

The function set_data() does not copy the data, it stores pointers to the data. If the data is modified, then the function reset_interp() must be called to reset the interpolation information with the original pointer information. The storage for the data, including the arrays x_grid and y_grid are all managed by the user.

By default, cubic spline interpolation with natural boundary conditions is used. This can be changed by calling set_interp() again with the same data and the new interpolation type. Only cubic spline and linear interpolation are supported.

Based on D. Zaslavsky's routines at https://github.com/diazona/interp2d (licensed under GPLv3).

Definition at line 100 of file interp2_direct.h.

Member Function Documentation

◆ eval_gen()

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>, class mat_row_t = boost::numeric::ublas::matrix_row<mat_t>, class mat_column_t = boost::numeric::ublas::matrix_column<mat_t>>
virtual double o2scl::interp2_direct< vec_t, mat_t, mat_row_t, mat_column_t >::eval_gen ( int  ix,
int  iy,
double  x0,
double  x1,
double  y0,
double  y1 
) const
inlinevirtual

This computes

\[ \frac{\partial^m}{\partial x^m} \frac{\partial^n}{\partial y^n} f(x,y) \]

for $ m \in (-1,0,1,2) $ and $ n \in (-1,0,1,2) $ with the notation

\begin{eqnarray*} \frac{\partial^{-1}}{\partial x^{-1}} &\equiv & \int_{x_0}^{x_1} f~dx \nonumber \\ \frac{\partial^0}{\partial x^0} &\equiv & \left.f\right|_{x=x_0} \nonumber \\ \frac{\partial^1}{\partial x^1} &\equiv & \left(\frac{\partial f}{\partial x}\right)_{x=x_0} \nonumber \\ \frac{\partial^2}{\partial x^2} &\equiv & \left(\frac{\partial^2 f}{\partial x^2}\right)_{x=x_0} \end{eqnarray*}

and the value of $ x_1 $ is ignored when $ m \geq 0 $ and the value of $ y_1 $ is ignored when $ n \geq 0 $.

Implements o2scl::interp2_base< vec_t, mat_t >.

Definition at line 750 of file interp2_direct.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).