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 template<typename RBF>
00016 class interpolator : public realfunc{
00017 public:
00018 interpolator();
00019
00020
00021 interpolator(shared_ptr<linear_BVP2> bvp);
00022
00023
00024 interpolator(const map<point, double>& Xi);
00025
00026
00027 void interpolate(const map<point, double>& Xi);
00028 void interpolate(shared_ptr<linear_BVP2> bvp);
00029
00030
00031 double operator()(const point& p) const;
00032 double at(const point& p) const;
00033
00034
00035 double d(const point& p, size_t k) const;
00036 double d2(const point &p, size_t k1, size_t k2) const;
00037
00038
00039
00040
00041 void set_f(const realfunc &f);
00042 void set_g(const realfunc &g);
00043 void set_f(const map<point, double>& f);
00044 void set_g(const map<point, double>& g);
00045
00046
00047 interpolator<RBF> operator+(const interpolator<RBF>& u) const;
00048 interpolator<RBF> operator*(double a) const;
00049 interpolator<RBF> operator/(double a) const;
00050
00051
00052 size_t rbfs_hash;
00053
00054 private:
00055
00056 void computecoeffs();
00057
00058 void init(shared_ptr<linear_BVP2> bvp);
00059
00060 shared_ptr<linear_BVP2> thebvp;
00061
00062
00063 size_t n;
00064
00065 size_t m;
00066
00067
00068 matrix M;
00069
00070 bool initted;
00071 void not_initted(int line, string file) const;
00072
00073 linalg::vector coeffs;
00074 std::vector<RBF> rbfs;
00075 size_t hash_value(const std::vector<RBF>& rbfs_in);
00076
00077
00078
00079
00080 typedef std::pair<linalg::point, std::vector<size_t> > diff_data;
00081
00082
00083 mutable map<diff_data, double> remtable;
00084 };
00085
00086
00087 template <typename RBF>
00088 interpolator<RBF> operator*(double a, const interpolator<RBF>& u)
00089 {
00090 return u*a;
00091 }
00092 }
00093
00094 #endif