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 FARFIELD_EXPANSION
00044 #define FARFIELD_EXPANSION
00045 
00046 #include "fastlib/fastlib.h"
00047 #include "kernel_aux.h"
00048 #include "series_expansion_aux.h"
00049 
00050 template<typename TKernelAux> 
00051 class LocalExpansion;
00052 
00064 template<typename TKernelAux>
00065 class FarFieldExpansion {
00066 
00067  private:
00068   
00070 
00072   Vector center_;
00073   
00075   Vector coeffs_;
00076 
00078   int order_;
00079   
00083   const TKernelAux *ka_;
00084 
00088   const typename TKernelAux::TKernel *kernel_;
00089 
00093   const typename TKernelAux::TSeriesExpansionAux *sea_;
00094 
00095   OT_DEF(FarFieldExpansion) {
00096     OT_MY_OBJECT(center_);
00097     OT_MY_OBJECT(coeffs_);
00098     OT_MY_OBJECT(order_);
00099   }
00100 
00101  public:
00102   
00104   
00110   double bandwidth_sq() const { return kernel_->bandwidth_sq(); }
00111 
00116   Vector* get_center() { return &center_; }
00117 
00118   const Vector* get_center() const { return &center_; }
00119 
00125   const Vector& get_coeffs() const { return coeffs_; }
00126   
00131   int get_order() const { return order_; }
00132   
00137   int get_max_order() const { return sea_->get_max_order(); }
00138 
00141   double get_weight_sum() const { return coeffs_[0]; }
00142 
00147   void set_order(int new_order) { order_ = new_order; }
00148   
00156   void set_center(const Vector &center) {
00157     
00158     for(index_t i = 0; i < center.length(); i++) {
00159       center_[i] = center[i];
00160     }
00161   }
00162 
00164   
00185   void Accumulate(const Vector &reference_point, double weight, int order);
00186 
00212   void AccumulateCoeffs(const Matrix& data, const Vector& weights,
00213                         int begin, int end, int order);
00214 
00218   void RefineCoeffs(const Matrix& data, const Vector& weights,
00219                     int begin, int end, int order);
00220   
00223   double EvaluateField(const Matrix& data, int row_num, int order) const;
00224   double EvaluateField(const double *x_q, int order) const;
00225 
00229   double MixField(const Matrix &data, int node1_begin, int node1_end, 
00230                   int node2_begin, int node2_end, const FarFieldExpansion &fe2,
00231                   const FarFieldExpansion &fe3, int order2, int order3) const;
00232 
00236   double ConvolveField(const FarFieldExpansion &fe, int order) const;
00237 
00241   double ConvolveField(const FarFieldExpansion &fe2,
00242                        const FarFieldExpansion &fe3,
00243                        int order1, int order2, int order3) const;
00244 
00248   void Init(const Vector& center, const TKernelAux &ka);
00249   void Init(const TKernelAux &ka);
00250 
00251   template<typename TBound>
00252   int OrderForConvolving(const TBound &far_field_region,
00253                          const Vector &far_field_region_centroid,
00254                          const TBound &local_field_region,
00255                          const Vector &local_field_region_centroid,
00256                          double min_dist_sqd_regions,
00257                          double max_dist_dsqd_regons,
00258                          double max_error, double *actual_error) const;
00259 
00264   template<typename TBound>
00265   int OrderForEvaluating(const TBound &far_field_region,
00266                          const TBound &local_field_region,
00267                          double min_dist_sqd_regions,
00268                          double max_dist_sqd_regions,
00269                          double max_error, double *actual_error) const;
00270 
00280   template<typename TBound>
00281   int OrderForConvertingToLocal(const TBound &far_field_region,
00282                                 const TBound &local_field_region, 
00283                                 double min_dist_sqd_regions, 
00284                                 double max_dist_sqd_regions,
00285                                 double required_bound, 
00286                                 double *actual_error) const;
00287 
00290   void PrintDebug(const char *name="", FILE *stream=stderr) const;
00291 
00296   void TranslateFromFarField(const FarFieldExpansion &se);
00297   
00302   void TranslateToLocal(LocalExpansion<TKernelAux> &se, int truncation_order);
00303 
00304 };
00305 
00306 #define INSIDE_FARFIELD_EXPANSION_H
00307 #include "farfield_expansion_impl.h"
00308 #undef INSIDE_FARFIELD_EXPANSION_H
00309 
00310 #endif
Generated on Mon Jan 24 12:04:38 2011 for FASTlib by  doxygen 1.6.3