mult_farfield_expansion.h

Go to the documentation of this file.
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_FARFIELD_EXPANSION
00044 #define MULT_FARFIELD_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 MultLocalExpansion;
00055 
00059 template<typename TKernelAux>
00060 class MultFarFieldExpansion {
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(MultFarFieldExpansion) {
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 
00111   double get_weight_sum() const { return coeffs_[0]; }
00112 
00114   void set_order(int new_order) { order_ = new_order; }
00115   
00120   void set_center(const Vector &center) {
00121     
00122     for(index_t i = 0; i < center.length(); i++) {
00123       center_[i] = center[i];
00124     }
00125   }
00126 
00127   // interesting functions...
00128   
00133   void AccumulateCoeffs(const Matrix& data, const Vector& weights,
00134                         int begin, int end, int order);
00135 
00140   void RefineCoeffs(const Matrix& data, const Vector& weights,
00141                     int begin, int end, int order);
00142   
00146   double EvaluateField(const Matrix& data, int row_num, int order) const;
00147   double EvaluateField(const double *x_q, int order) const;
00148 
00153   double MixField(const Matrix &data, int node1_begin, int node1_end, 
00154                   int node2_begin, int node2_end,
00155                   const MultFarFieldExpansion &fe2,
00156                   const MultFarFieldExpansion &fe3,
00157                   int order2, int order3) const;
00158 
00159   double ConvolveField(const MultFarFieldExpansion &fe, int order) const;
00160 
00165   double ConvolveField(const MultFarFieldExpansion &fe2,
00166                        const MultFarFieldExpansion &fe3,
00167                        int order1, int order2, int order3) const;
00168   
00173   void Init(const Vector& center, const TKernelAux &ka);
00174   void Init(const TKernelAux &ka);
00175 
00180   template<typename TBound>
00181   int OrderForEvaluating(const TBound &far_field_region,
00182                          const TBound &local_field_region,
00183                          double min_dist_sqd_regions,
00184                          double max_dist_sqd_regions,
00185                          double max_error, double *actual_error) const;
00186 
00196   template<typename TBound>
00197   int OrderForConvertingToLocal(const TBound &far_field_region,
00198                                 const TBound &local_field_region, 
00199                                 double min_dist_sqd_regions, 
00200                                 double max_dist_sqd_regions,
00201                                 double required_bound, 
00202                                 double *actual_error) const;
00203 
00207   void PrintDebug(const char *name="", FILE *stream=stderr) const;
00208 
00213   void TranslateFromFarField(const MultFarFieldExpansion &se);
00214   
00219   void TranslateToLocal(MultLocalExpansion<TKernelAux> &se, 
00220                         int truncation_order);
00221 
00222 };
00223 
00224 #define INSIDE_MULT_FARFIELD_EXPANSION_H
00225 #include "mult_farfield_expansion_impl.h"
00226 #undef INSIDE_MULT_FARFIELD_EXPANSION_H
00227 
00228 #endif
Generated on Mon Jan 24 12:04:38 2011 for FASTlib by  doxygen 1.6.3