mult_local_expansion.h

00001 /* MLPACK 0.2
00002  *
00003  * Copyright (c) 2008, 2009 Alexander Gray,
00004  *                          Garry Boyer,
00005  *                          Ryan Riegel,
00006  *                          Nikolaos Vasiloglou,
00007  *                          Dongryeol Lee,
00008  *                          Chip Mappus, 
00009  *                          Nishant Mehta,
00010  *                          Hua Ouyang,
00011  *                          Parikshit Ram,
00012  *                          Long Tran,
00013  *                          Wee Chin Wong
00014  *
00015  * Copyright (c) 2008, 2009 Georgia Institute of Technology
00016  *
00017  * This program is free software; you can redistribute it and/or
00018  * modify it under the terms of the GNU General Public License as
00019  * published by the Free Software Foundation; either version 2 of the
00020  * License, or (at your option) any later version.
00021  *
00022  * This program is distributed in the hope that it will be useful, but
00023  * WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  * General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU General Public License
00028  * along with this program; if not, write to the Free Software
00029  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00030  * 02110-1301, USA.
00031  */
00043 #ifndef MULT_LOCAL_EXPANSION
00044 #define MULT_LOCAL_EXPANSION
00045 
00046 #include <climits>
00047 //#include <values.h>
00048 
00049 #include "fastlib/fastlib.h"
00050 #include "kernel_aux.h"
00051 #include "mult_series_expansion_aux.h"
00052 
00053 template<typename TKernelAux> 
00054 class MultFarFieldExpansion;
00055 
00059 template<typename TKernelAux>
00060 class MultLocalExpansion {
00061 
00062  private:
00063 
00065   Vector center_;
00066   
00068   Vector coeffs_;
00069   
00071   int order_;
00072   
00074   const TKernelAux *ka_;
00075 
00077   const typename TKernelAux::TKernel *kernel_;
00078 
00080   const typename TKernelAux::TSeriesExpansionAux *sea_;
00081 
00082   OT_DEF(MultLocalExpansion) {
00083     OT_MY_OBJECT(center_);
00084     OT_MY_OBJECT(coeffs_);
00085     OT_MY_OBJECT(order_);
00086   }
00087   
00088  public:
00089   
00090   // getters and setters
00091   
00093   double bandwidth_sq() const { return kernel_->bandwidth_sq(); }
00094   
00096   Vector* get_center() { return &center_; }
00097 
00098   const Vector* get_center() const { return &center_; }
00099 
00101   const Vector& get_coeffs() const { return coeffs_; }
00102   
00104   int get_order() const { return order_; }
00105 
00107   int get_max_order() const { return sea_->get_max_order(); }
00108 
00110   void set_order(int new_order) { order_ = new_order; }
00111 
00112   // interesting functions...
00113   
00118   void AccumulateCoeffs(const Matrix& data, const Vector& weights,
00119                         int begin, int end, int order);
00120 
00124   void RefineCoeffs(const Matrix& data, const Vector& weights,
00125                     int begin, int end, int order) { }
00126   
00130   double EvaluateField(const Matrix& data, int row_num) const;
00131   double EvaluateField(const Vector& x_q) const;
00132   
00137   void Init(const Vector& center, const TKernelAux &sea);
00138   void Init(const TKernelAux &sea);
00139   
00144   template<typename TBound>
00145   int OrderForEvaluating(const TBound &far_field_region,
00146                          const TBound &local_field_region,
00147                          double min_dist_sqd_regions,
00148                          double max_dist_sqd_regions,
00149                          double max_error, double *actual_error) const;
00150 
00154   void PrintDebug(const char *name="", FILE *stream=stderr) const;
00155 
00160   void TranslateFromFarField(const MultFarFieldExpansion<TKernelAux> &se);
00161   
00166   void TranslateToLocal(MultLocalExpansion &se);
00167 
00168 };
00169 
00170 #define INSIDE_MULT_LOCAL_EXPANSION_H
00171 #include "mult_local_expansion_impl.h"
00172 #undef INSIDE_MULT_LOCAL_EXPANSION_H
00173 
00174 #endif
Generated on Mon Jan 24 12:04:38 2011 for FASTlib by  doxygen 1.6.3