00001
00002
00003
00004
00005
00006
00007
00008 #ifndef Hankel_H
00009 #define Hankel_H
00010
00011 #include <synaps/init.h>
00012 #include <synaps/linalg/rep1d.h>
00013 #include <synaps/base/Range.h>
00014 #include <synaps/linalg/FFT.h>
00015
00016 __BEGIN_NAMESPACE_SYNAPS
00017
00018
00019 template<char O,class A, class B> struct OP;
00020
00021 namespace linalg {
00022
00031 template<class C>
00032 struct hankel : public linalg::rep1d<C> {
00033
00034 unsigned int nbrow_, nbcol_;
00035
00036 typedef C coeff_t;
00037 typedef typename linalg::rep1d<C>::size_type size_type;
00038 typedef rep1d<C> row_t;
00039 typedef rep1d<C> col_t;
00040
00041 hankel(): rep1d<C>(){}
00042 hankel(const hankel<C> & v): rep1d<C>(v),
00043 nbrow_(v.nbrow_), nbcol_(v.nbcol_){}
00044 hankel(unsigned int i, unsigned int j):
00045 rep1d<C>(i+j-1),nbrow_(i),nbcol_(j) {}
00046 hankel(unsigned int i, unsigned int j, C* t):
00047 rep1d<C>(i+j-1,t),nbrow_(i),nbcol_(j){}
00048
00049 void resize(unsigned int i, unsigned int j)
00050 {
00051 this->rep1d<C>::resize(i+j-1); nbrow_ = i; nbcol_=j;
00052 }
00053
00054
00055 C operator()(unsigned int i, unsigned int j) const
00056 {return this->tab_[i+j];}
00057
00058 size_type nbrow() const {return nbrow_;}
00059 size_type nbcol() const {return nbcol_;}
00060
00061 void transpose() { std::swap(nbcol_,nbrow_);};
00062 };
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 template<class C, class M>
00074 void submatrix( hankel<C> & r, const M & m, const Range2d & rg )
00075 {
00076 typedef typename hankel<C>::size_type size_type;
00077 for(size_type i=rg.j1; i< rg.j2+1; i++)
00078 r[i-rg.j1]=m(rg.i1,i);
00079 for(size_type i=rg.i1+1; i< rg.i2+1; i++)
00080 r[i+rg.j2-rg.j1-rg.i1]=m(i,rg.j2);
00081 }
00082
00083
00084
00085 template<class S, class C>
00086 inline void assign(hankel<C> & r, S M)
00087 {
00088 for(unsigned int i=0;i<M.nbcol();i++) r(0,i)=M(0,i);
00089 unsigned int c= M.nbcol()-1;
00090 for(unsigned int i=1;i<M.nbrow();i++) r(i,c)=M(i,c);
00091 }
00092
00097 template<class C,class V>
00098 void mult_vect(V & r, const hankel<C> & t, const V & v);
00099
00100 }
00101
00102 __END_NAMESPACE_SYNAPS
00103
00104
00105 #ifndef SEPARATE_COMPILATION
00106 #include "synaps/linalg/hankel.C"
00107 #endif
00108
00109
00110 #endif //hankel_H
00111