Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

cluster/cebysev.hh
Go to the documentation of this file.
00001 /* Cebysev kernel expansion
00002  */
00003 
00004 #ifndef cebysev_hh
00005 #define cebysev_hh
00006 
00007 #include "basics/exceptions.hh"
00008 #include "cluster/expansion.hh"
00009 
00010 namespace cluster {
00011 
00012   // ******************************************************* CebysevLaplaceF **
00013 
00017   template <class Fspc = concepts::Real>
00018   class CebysevLaplaceF : public ExpansionF<Fspc> {
00019 
00022     class FColCebyLpl : public FColExp {
00023     public:
00024       concepts::Real* val;
00025 
00026       inline FColCebyLpl(uint blksz) {val = new concepts::Real[blksz];}
00027       inline ~FColCebyLpl() {delete[] val;}
00028 
00029       uint memory(uint blksz) const {
00030         return sizeof(FColCebyLpl) + blksz * sizeof(concepts::Real);
00031       }
00032       void info(std::ostream& os, uint blksz) const {
00033         for(uint i = 0; i < blksz-1; i++)  os << val[i] << ", ";
00034         os << val[blksz-1];
00035       }
00036     };
00037 
00039     uint m_;
00041     concepts::Real eta_;
00043     concepts::Real** cebysev_;
00045     concepts::Real* x_;
00046     concepts::Real* y_;
00047     concepts::Real* z_;
00049     concepts::Real* kernel_;
00051     concepts::Real* d_;
00052     concepts::Real* dd_;
00053   
00054     inline int index_(int ix, int iy, int iz) const;
00055   
00056   public:
00061     CebysevLaplaceF(uint m, concepts::Real eta);
00062     
00063     virtual ~CebysevLaplaceF();
00064 
00065     uint blksz(uint m) const {return (m * (m * (m + 3) + 2)) / 6;}
00066     uint m() const {return m_;}
00068     virtual FColReal* getCol(uint blksz) const {
00069       return new FColReal(blksz);
00070     }
00071 
00073     void fit(uint m, const concepts::Real3d& z, concepts::Real F[]) const;
00075     void ceby2poly(uint m, const concepts::Real3d& z,
00076        concepts::Real F[]) const;
00077 
00079     inline void evaluate(uint m, const concepts::Real3d& z,
00080        FColExp* Fexp) const;
00081     inline void evaluate(uint m, const concepts::Real3d& z,
00082        FColReal Fexp[]) const;
00084     inline void apply(uint m, const FColExp* Fexp, const Fspc src[],
00085           Fspc dst[]) const;
00086     void apply(uint m, const FColReal Fexp[], const Fspc src[],
00087          Fspc dst[]) const;
00088   };
00089 
00090   template <class Fspc>
00091   inline int CebysevLaplaceF<Fspc>::index_(int ix, int iy, int iz) const {
00092     int m = ix + iy + iz;
00093     return (((m+3)*m+2)*m + ((3-ix)*3*ix)) / 6 + m*ix + iy;
00094   }
00095 
00096   template <class Fspc>
00097   inline void CebysevLaplaceF<Fspc>::evaluate(uint m,
00098                 const concepts::Real3d& z,
00099                 FColExp* Fexp) const {
00100     FColReal* fexp = dynamic_cast<FColReal*>(Fexp);
00101     if (fexp) {
00102       concepts::Real* F = fexp->value();
00103       fit(m, z, F); ceby2poly(m, z, F);
00104       return;
00105     }
00106 
00107     throw
00108       conceptsException(concepts::MissingFeature("FColExp not supported"));
00109   }
00110 
00111   template <class Fspc>
00112   inline void CebysevLaplaceF<Fspc>::evaluate(uint m,
00113                 const concepts::Real3d& z,
00114                 FColReal Fexp[]) const {
00115     concepts::Real* F = Fexp->value();
00116     fit(m, z, F);  ceby2poly(m, z, F);
00117     return;
00118   }
00119 
00120   template <class Fspc>
00121   inline void CebysevLaplaceF<Fspc>::apply(uint m, const FColExp* Fexp,
00122              const Fspc src[], Fspc dst[]) const {
00123     const FColReal* fexp = dynamic_cast<const FColReal*>(Fexp);
00124     if (fexp) {apply(m, fexp, src, dst);  return;}
00125 
00126     throw
00127       conceptsException(concepts::MissingFeature("FColExp not supported"));
00128   }
00129 
00130 } // namespace cluster
00131 
00132 #endif // cebysev_hh
00133 

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)