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

aglowav/operator.hh
Go to the documentation of this file.
00001 /* Operators for the agglomerated wavelets.
00002  */
00003 
00004 #ifndef aglowavOperator_hh
00005 #define aglowavOperator_hh
00006 
00007 #ifdef __GUNG__
00008   #pragma interface
00009 #endif
00010 
00011 #include <vector>
00012 
00013 #include "basics/exceptions.hh"
00014 #include "basics/memory.hh"
00015 #include "operator/compositions.hh"
00016 #include "aglowav/space.hh"
00017 
00018 namespace aglowav {
00019 
00020   // ******************************************************************* C2W **
00021 
00026   template<class F = concepts::Real>
00027   class C2W : public concepts::Operator<F> {
00028   public:
00032     C2W(const concepts::Space<F>& cnst, const Haar3d<F>& wav);
00033 
00037     void operator()(const concepts::Function<F>& fncC,
00038                     concepts::Function<F>& fncW);
00040     void operator()(const concepts::Vector<F>& fncC,
00041                     concepts::Vector<F>& fncW);
00043     const Haar3d<F>& spaceX() const {return wav_;}
00044     const concepts::Space<F>&  spaceY() const {return cnst_;}
00045 
00046   protected:
00048     std::ostream& info(std::ostream& os) const;
00049 
00050   private:
00052     const Haar3d<F>&          wav_;
00053     const concepts::Space<F>& cnst_;
00054   };
00055 
00056   template<class F>
00057   C2W<F>::C2W(const concepts::Space<F>& cnst, const Haar3d<F>& wav)
00058     : concepts::Operator<F>(wav.dim(), cnst.dim()), wav_(wav), cnst_(cnst)
00059   {
00060     conceptsAssert(wav_.dim() == cnst_.dim(), concepts::Assertion());
00061   }
00062 
00063   // ******************************************************************* W2C **
00064 
00069   template<class F = concepts::Real>
00070   class W2C : public concepts::Operator<F> {
00071   public:
00075     W2C(const Haar3d<F>& wav, const concepts::Space<F>& cnst);
00076 
00077     /* Transformation from fncW to fncC
00078        @throw MissingFeature
00079     */
00080     void operator()(const concepts::Function<F>& fncW,
00081         concepts::Function<F>& fncC);
00083     void operator()(const concepts::Vector<F>& fncW,
00084         concepts::Vector<F>& fncC);
00086     const concepts::Space<F>& spaceX() const {return cnst_;}
00087     //const AdaptConst3d<IK>& spaceX() const;
00088     const Haar3d<F>& spaceY() const {return wav_;}
00089 
00090   protected:
00092     std::ostream& info(std::ostream& os) const;
00093 
00094   private:
00096     const concepts::Space<F>& cnst_;
00097     const Haar3d<F>&          wav_;
00098   };
00099 
00100   template<class F>
00101   W2C<F>::W2C(const Haar3d<F>& wav, const concepts::Space<F>& cnst)
00102     : concepts::Operator<F>(wav.dim(), cnst.dim()), cnst_(cnst), wav_(wav)
00103   {
00104     conceptsAssert(wav_.dim() == cnst_.dim(), concepts::Assertion());
00105   }
00106 
00107   // **************************************************************** C2_tl2 **
00108 
00115   template<class F = concepts::Real>
00116   class C2_tl2 : public concepts::Operator<F> {
00117   public:
00121     C2_tl2(const BiHaar3d<F>& spc, concepts::Real t);
00123     ~C2_tl2() {delete[] val_; delete[] idx_;}
00124 
00128     void operator()(const concepts::Function<F>& fncY,
00129         concepts::Function<F>& fncX);
00130     void operator()(const concepts::Vector<F>& fncY,
00131         concepts::Vector<F>& fncX);
00133     const BiHaar3d<F>& spaceX() const {return spc_;}
00134     const BiHaar3d<F>& spaceY() const {return spc_;}
00135 
00136   protected:
00138     std::ostream& info(std::ostream& os) const;
00139 
00140   private:
00142     const BiHaar3d<F>& spc_;
00143     concepts::Real t_;
00145     concepts::Real* val_;
00147     concepts::Real** idx_;
00148   };
00149 
00150   // ***************************************************************** C2tl2 **
00151 
00159   template<class F = concepts::Real>
00160   class C2tl2 : public concepts::Operator<F> {
00161   public:
00165     C2tl2(const BiHaar3d<F>& spc, concepts::Real t);
00167     ~C2tl2() {delete[] val_; delete[] idx_;}
00168 
00172     void operator()(const concepts::Function<F>& fncY,
00173                     concepts::Function<F>& fncX);
00174     void operator()(const concepts::Vector<F>& fncY,
00175                     concepts::Vector<F>& fncX);
00177     const BiHaar3d<F>& spaceX() const {return spc_;}
00178     const BiHaar3d<F>& spaceY() const {return spc_;}
00179 
00180   protected:
00182     std::ostream& info(std::ostream& os) const;
00183 
00184   private:
00186     const BiHaar3d<F>& spc_;
00187     concepts::Real t_;
00189     concepts::Real* val_;
00191     concepts::Real** idx_;
00192   };
00193 
00194   // ****************************************************************** CGt2 **
00195 
00204   template<class F = concepts::Real>
00205   class CGt2 : public concepts::Operator<F> {
00206   public:
00208     CGt2(const Haar3d<F>& spc, concepts::Real t);
00209 
00213     void operator()(const concepts::Function<F>& fncY,
00214         concepts::Function<F>& fncX);
00215     void operator()(const concepts::Vector<F>& fncY,
00216         concepts::Vector<F>& fncX);
00218     const Haar3d<F>& spaceX() const {return spc_;}
00219     const Haar3d<F>& spaceY() const {return spc_;}
00220 
00221   protected:
00223     std::ostream& info(std::ostream& os) const;
00224 
00225   private:
00227     const Haar3d<F>& spc_;
00228     concepts::Real t_;
00230     std::vector<concepts::Real> val_;
00231   };
00232 
00233   // ************************************************************** ComposeN **
00234 
00239   template<class F = concepts::Real>
00240   class ComposeN : public concepts::Operator<F> {
00242     uint                    n_;
00244     concepts::Operator<F>** ops_;
00246     concepts::Vector<F>**   f_;
00247 
00248   public:
00253     ComposeN(concepts::Operator<F>** ops, uint n);
00254     ~ComposeN();
00255 
00257     void operator()(const concepts::Function<F>& fncY,
00258                     concepts::Function<F>& fncX);
00259   protected:
00260     std::ostream& info(std::ostream& os) const;
00261   };
00262 
00263   template<class F>
00264   inline ComposeN<F>::ComposeN(concepts::Operator<F>** ops, uint n) 
00265     : concepts::Operator<F>(ops[0]->dimX(), ops[n-1]->dimY()), n_(n)
00266   {
00267     conceptsAssert(n > 1, concepts::Assertion());
00268     ops_ = concepts::newField<concepts::Operator<F>*>(n_);
00269     for(uint i = 0; i < n_; i++)  ops_[i] = ops[i];
00270     f_ = concepts::newField<concepts::Vector<F>*>(n_-1);
00271     for(uint j = 0; j < n_-1; j++)
00272       f_[j] = new concepts::Vector<F>(ops_[j]->dimY());
00273   }
00274 
00275   template<class F>
00276   inline ComposeN<F>::~ComposeN() {
00277     for(uint i = 0; i < n_-1; i++)  delete f_[i];
00278     delete[] f_;
00279     delete[] ops_;
00280   }
00281 
00282   template<class F>
00283   inline void ComposeN<F>::operator()(const concepts::Function<F>& fncY,
00284                                       concepts::Function<F>& fncX) {
00285 
00286     conceptsAssert((fncY.dim() == this->dimY()) &&
00287                    (fncX.dim() == this->dimX()), concepts::Assertion());
00288 
00289     ops_[n_-1]->operator()(fncY, *f_[n_-2]);
00290     for(uint i = n_-1; --i;)  ops_[i]->operator()(*f_[i], *f_[i-1]);
00291     ops_[0]->operator()(*f_[0], fncX);
00292   }
00293 
00294   template<class F>
00295   std::ostream& ComposeN<F>::info(std::ostream& os) const {
00296     return os << "aglowav::ComposeN -- (op1 * ... * op" << n_ << ")";
00297   }
00298 
00299 } // namespace aglowav
00300 
00301 #endif // aglowavOperator_hh

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