interp2_eqi.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2017, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_INTERP2_EQI_H
24 #define O2SCL_INTERP2_EQI_H
25 
26 /** \file interp2_eqi.h
27  \brief File defining \ref o2scl::interp2_eqi
28 */
29 
30 #include <iostream>
31 #include <string>
32 
33 #ifndef DOXYGEN_NO_O2NS
34 namespace o2scl {
35 #endif
36 
37  /** \brief Two-dimensional interpolation for equally-spaced intervals
38 
39  \note This class is unfinished.
40 
41  This implements the relations from Abramowitz and Stegun:
42  \f[
43  f(x_0+p h,y_0+q k)=
44  \f]
45  3-point
46  \f[
47  (1-p-q) f_{0,0}+p f_{1,0}+q f_{0,1}
48  \f]
49  4-point
50  \f[
51  (1-p)(1-q) f_{0,0}+p(1-q)f_{1,0}+q(1-p)f_{0,1}+pqf_{1,1}
52  \f]
53  6-point
54  \f[
55  \frac{q(q-1)}{2}f_{0,-1}+\frac{p(p-1)}{2}f_{-1,0}+
56  (1+pq-p^2-q^2)f_{0,0}+\frac{p(p-2q+1)}{2}f_{1,0}+
57  \frac{q(q-2p+1)}{2}f_{0,1}+pqf_{1,1}
58  \f]
59  */
60  class interp2_eqi {
61 
62  public:
63 
64  interp2_eqi();
65 
66  /** \brief Perform the 2-d interpolation
67  */
68  double interp(double x, double y);
69 
70  /** \brief Offset in x-direction
71  */
72  double xoff;
73 
74  /** \brief Offset in y-direction
75  */
76  double yoff;
77 
78  /** \brief Set the interpolation type
79 
80  - 3: 3-point
81  - 4: 4-point
82  - 6: 6-point (default)
83  */
84  int set_type(int type) {
85  if (type<=0) itype=6;
86  else if (type<=3) itype=3;
87  else if (type>=5) itype=6;
88  else type=4;
89  return 0;
90  }
91 
92 #ifndef DOXYGEN_NO_O2NS
93 
94  protected:
95 
96  int itype;
97 
98 #endif
99 
100  };
101 
102 #ifndef DOXYGEN_NO_O2NS
103 }
104 #endif
105 
106 #endif
107 
108 
109 
The main O<span style=&#39;position: relative; top: 0.3em; font-size: 0.8em&#39;>2</span>scl O$_2$scl names...
Definition: anneal.h:42
double yoff
Offset in y-direction.
Definition: interp2_eqi.h:76
double xoff
Offset in x-direction.
Definition: interp2_eqi.h:72
Two-dimensional interpolation for equally-spaced intervals.
Definition: interp2_eqi.h:60
int set_type(int type)
Set the interpolation type.
Definition: interp2_eqi.h:84
double interp(double x, double y)
Perform the 2-d interpolation.

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