00001 #ifndef __INTERPOLATOR_H__
00002 #define __INTERPOLATOR_H__
00003
00004 #include <vector>
00005 #include <map>
00006 #include <boost/shared_ptr.hpp>
00007 #include "bvp.hpp"
00008 #include "linalg.hpp"
00009 #include "func.hpp"
00010 #include "diff_op.hpp"
00011
00012 namespace bvp{
00013 using std::map;
00014 using boost::shared_ptr;
00015
00016 template<typename RBF>
00017 class interpolator : public realfunc{
00018 public:
00019
00026
00027 interpolator();
00028
00030 interpolator(shared_ptr<linear_BVP2> bvp);
00031
00033 interpolator(const map<point, double>& Xi);
00034
00041 interpolator(shared_ptr<domain> Omega, const map<point, double>& Xi);
00043
00049 void interpolate(const map<point, double>& Xi);
00050 void interpolate(shared_ptr<linear_BVP2> bvp);
00052
00056
00057 double operator()(const point& p) const;
00059 double at(const point& p) const;
00060
00062 double d(const point& p, size_t k) const;
00064 double d2(const point &p, size_t k1, size_t k2) const;
00066
00074 void set_f(const realfunc &f);
00075 void set_g(const realfunc &g);
00076 void set_f(const map<point, double>& f);
00077 void set_g(const map<point, double>& g);
00079
00085
00086 interpolator<RBF> operator+(const interpolator<RBF>& u) const;
00088 interpolator<RBF> operator-(const interpolator<RBF>& u) const;
00089 interpolator<RBF> operator*(double a) const;
00090 interpolator<RBF> operator/(double a) const;
00092
00093 private:
00094
00095 void computecoeffs();
00096
00097 void init(shared_ptr<linear_BVP2> bvp);
00098
00099 shared_ptr<linear_BVP2> thebvp;
00100
00101
00102 size_t n;
00103
00104 size_t m;
00105
00106
00107 matrix M;
00108
00109 bool initted;
00110 void not_initted(int line, string file) const;
00111
00112 linalg::vector coeffs;
00113 std::vector<RBF> rbfs;
00114 size_t rbfs_hash;
00115
00116 size_t hash_value(const std::vector<RBF>& rbfs_in);
00117
00118
00119
00120
00121 typedef std::pair<linalg::point, std::vector<size_t> > diff_data;
00122
00123
00124 mutable map<diff_data, double> remtable;
00125 };
00126
00127
00128 template <typename RBF>
00129 interpolator<RBF> operator*(double a, const interpolator<RBF>& u)
00130 {
00131 return u*a;
00132 }
00133 }
00134
00135 #endif