Go to the documentation of this file.00001
00002
00003
00004 #ifndef expansion_hh
00005 #define expansion_hh
00006
00007 #include "basics/vectorsMatricesForward.hh"
00008 #include "space/element.hh"
00009
00010 namespace cluster {
00011
00012
00013
00016 class XYColExpPtr {
00017 public:
00018 virtual void operator+=(uint i) = 0;
00019 virtual void operator-=(uint i) = 0;
00020 };
00021
00022
00023
00026 template <class F = concepts::Real>
00027 class XYColFPtr : public XYColExpPtr {
00028 public:
00029 XYColFPtr() : val_(0) {}
00030 XYColFPtr(F* val) : val_(val) {}
00031
00032 void operator+=(uint i) {val_ += i;}
00033 void operator-=(uint i) {val_ -= i;}
00034
00035 inline F* value() const {return val_;}
00036
00037 protected:
00038 F* val_;
00039 };
00040
00041
00042
00045 class XYColExp : public XYColExpPtr {
00046 public:
00047 virtual ~XYColExp() {}
00048
00049 virtual XYColExpPtr* operator[](uint i) const = 0;
00050 virtual uint memory() const = 0;
00051 };
00052
00053
00054
00057 template <class F = concepts::Real>
00058 class XYColF : public XYColExp, public XYColFPtr<F> {
00059 public:
00060 typedef XYColFPtr<F> ColPtr;
00061
00062 inline XYColF(uint blksz, uint n) : blksz_(blksz), n_(n) {
00063 this->val_ = new F[blksz_*n_];
00064 std::memset(this->val_, 0, blksz_ * n_ * sizeof(F));
00065 }
00066 inline ~XYColF() {delete[] this->val_;}
00067
00068 XYColFPtr<F>* operator[](uint i) const {
00069 return new XYColFPtr<F>(&this->val_[i*blksz_]);
00070 }
00071 uint memory() const {return sizeof(XYColF<F>) + blksz_ * n_ * sizeof(F);}
00072 void operator+=(uint i) {
00073 throw conceptsException(concepts::ExceptionBase());
00074 }
00075 void operator-=(uint i) {
00076 throw conceptsException(concepts::ExceptionBase());
00077 }
00078
00079 private:
00080 uint blksz_;
00081 uint n_;
00082 };
00083
00084
00085
00086 typedef XYColFPtr<concepts::Real> XYColRealPtr;
00087 typedef XYColF<concepts::Real> XYColReal;
00088
00089
00090
00095 template <class F = concepts::Real>
00096 class ExpansionXY {
00097 public:
00098 virtual ~ExpansionXY() {}
00099
00101 virtual uint blksz() const = 0;
00103 virtual uint m() const = 0;
00108 virtual XYColExp* getCol(uint blksz, uint n) const = 0;
00115 virtual void evaluate(const concepts::Element<F>& elm,
00116 const concepts::Real3d& c,
00117 XYColExpPtr* XY[]) const = 0;
00123 virtual void shift(const concepts::Real3d& z, const concepts::Real src[],
00124 concepts::Real dst[]) const = 0;
00125 virtual void shift(const concepts::Real3d& z, const concepts::Cmplx src[],
00126 concepts::Cmplx dst[]) const = 0;
00133 virtual void apply(const XYColExpPtr* XY, const F src[],
00134 F dst[]) const = 0;
00135 };
00136
00137
00138
00141 class FColExp {
00142 friend std::ostream& operator<<(std::ostream& os, const FColExp& f);
00143 public:
00144 virtual ~FColExp() {}
00145 virtual uint memory(uint blksz) const = 0;
00146 virtual void info(std::ostream& os, uint) const { os << "FColExp()"; }
00147 };
00148
00149
00150
00153 template <class F = concepts::Real>
00154 class FColF : public FColExp {
00155 public:
00156 inline FColF(uint blksz) {this->val_ = new F[blksz];}
00157 inline ~FColF() {delete[] this->val_;}
00158
00159 inline F* value() const {return this->val_;}
00160 uint memory(uint blksz) const {
00161 return sizeof(FColF<F>) + blksz * sizeof(F);
00162 }
00163 void info(std::ostream& os, uint blksz) const {
00164 for(uint i = 0; i < blksz-1; i++) os << this->val_[i] << ", ";
00165 os << this->val_[blksz-1];
00166 }
00167
00168 private:
00169 F* val_;
00170 };
00171
00172
00173
00174 typedef FColF<concepts::Real> FColReal;
00175
00176
00177
00182 template <class Fspc = concepts::Real>
00183 class ExpansionF {
00184 public:
00185 virtual ~ExpansionF() {}
00186
00190 virtual uint blksz(uint m) const = 0;
00192 virtual uint m() const = 0;
00195 virtual FColExp* getCol(uint blksz) const = 0;
00202 virtual void evaluate(uint m, const concepts::Real3d& z,
00203 FColExp* Fexp) const = 0;
00211 virtual void apply(uint m, const FColExp* Fexp, const Fspc src[],
00212 Fspc dst[]) const = 0;
00213 };
00214
00215 }
00216
00217 #endif // expansion_hh