twod_eqi_intp.h

00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006, 2007, Andrew W. Steiner
00005   
00006   This file is part of O2scl.
00007   
00008   O2scl is free software; you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation; either version 3 of the License, or
00011   (at your option) any later version.
00012   
00013   O2scl is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017   
00018   You should have received a copy of the GNU General Public License
00019   along with O2scl. If not, see <http://www.gnu.org/licenses/>.
00020 
00021   -------------------------------------------------------------------
00022 */
00023 #ifndef O2SCL_TWOD_EQI_INTP_H
00024 #define O2SCL_TWOD_EQI_INTP_H
00025 
00026 #include <iostream>
00027 #include <string>
00028 
00029 #ifndef DOXYGENP
00030 namespace o2scl {
00031 #endif
00032 
00033   /** 
00034       \brief Two-dimensional interpolation for equally-spaced intervals
00035 
00036       This implements the relations from Abramowitz and Stegun:
00037       \f[
00038       f(x_0+p h,y_0+q k)=
00039       \f]
00040       3-point
00041       \f[
00042       (1-p-q) f_{0,0}+p f_{1,0}+q f_{0,1}
00043       \f]
00044       4-point
00045       \f[
00046       (1-p)(1-q) f_{0,0}+p(1-q)f_{1,0}+q(1-p)f_{0,1}+pqf_{1,1}
00047       \f]
00048       6-point
00049       \f[
00050       \frac{q(q-1)}{2}f_{0,-1}+\frac{p(p-1)}{2}f_{-1,0}+
00051       (1+pq-p^2-q^2)f_{0,0}+\frac{p(p-2q+1)}{2}f_{1,0}+
00052       \frac{q(q-2p+1)}{2}f_{0,1}+pqf_{1,1}
00053       \f]
00054   */
00055   class twod_eqi_intp {
00056   public:
00057     
00058     twod_eqi_intp();
00059 
00060     /** \brief Perform the 2-d interpolation 
00061      */
00062     double interp(double x, double y);
00063 
00064     /** \brief Offset in x-direction 
00065      */
00066     double xoff;
00067     
00068     /** \brief Offset in y-direction 
00069      */
00070     double yoff;
00071 
00072     /** \brief Set the interpolation type
00073 
00074         - 3: 3-point
00075         - 4: 4-point
00076         - 6: 6-point (default)
00077      */
00078     int set_type(int type) {
00079       if (type<=0) itype=6;
00080       else if (type<=3) itype=3;
00081       else if (type>=5) itype=6;
00082       else type=4;
00083       return 0;
00084     }
00085 
00086 #ifndef DOXYGENP
00087 
00088   protected:
00089 
00090     int itype;
00091 
00092 #endif
00093 
00094   };
00095   
00096 #ifndef DOXYGENP
00097 }
00098 #endif
00099 
00100 #endif
00101 
00102 
00103 

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page