expansion.hh

Go to the documentation of this file.
1 
6 #ifndef expansion_hh
7 #define expansion_hh
8 
10 #include "space/element.hh"
11 
12 namespace cluster {
13 
14  // *********************************************************** XYColExpPtr **
15 
18  class XYColExpPtr {
19  public:
20  virtual void operator+=(uint i) = 0;
21  virtual void operator-=(uint i) = 0;
22  };
23 
24  // ************************************************************* XYColFPtr **
25 
28  template <class F = concepts::Real>
29  class XYColFPtr : public XYColExpPtr {
30  public:
31  XYColFPtr() : val_(0) {}
32  XYColFPtr(F* val) : val_(val) {}
33 
34  void operator+=(uint i) {val_ += i;}
35  void operator-=(uint i) {val_ -= i;}
36 
37  inline F* value() const {return val_;}
38 
39  protected:
40  F* val_;
41  };
42 
43  // ************************************************************** XYColExp **
44 
47  class XYColExp : public XYColExpPtr {
48  public:
49  virtual ~XYColExp() {}
50 
51  virtual XYColExpPtr* operator[](uint i) const = 0;
52  virtual uint memory() const = 0;
53  };
54 
55  // **************************************************************** XYColF **
56 
59  template <class F = concepts::Real>
60  class XYColF : public XYColExp, public XYColFPtr<F> {
61  public:
63 
64  inline XYColF(uint blksz, uint n) : blksz_(blksz), n_(n) {
65  this->val_ = new F[blksz_*n_];
66  std::memset(this->val_, 0, blksz_ * n_ * sizeof(F));
67  }
68  inline ~XYColF() {delete[] this->val_;}
69 
70  XYColFPtr<F>* operator[](uint i) const {
71  return new XYColFPtr<F>(&this->val_[i*blksz_]);
72  }
73  uint memory() const {return sizeof(XYColF<F>) + blksz_ * n_ * sizeof(F);}
74  void operator+=(uint i) {
76  }
77  void operator-=(uint i) {
79  }
80 
81  private:
82  uint blksz_;
83  uint n_;
84  };
85 
86  // ************************************************************** typedefs **
87 
90 
91  // *********************************************************** ExpansionXY **
92 
97  template <class F = concepts::Real>
98  class ExpansionXY {
99  public:
100  virtual ~ExpansionXY() {}
101 
103  virtual uint blksz() const = 0;
105  virtual uint m() const = 0;
110  virtual XYColExp* getCol(uint blksz, uint n) const = 0;
117  virtual void evaluate(const concepts::Element<F>& elm,
118  const concepts::Real3d& c,
119  XYColExpPtr* XY[]) const = 0;
125  virtual void shift(const concepts::Real3d& z, const concepts::Real src[],
126  concepts::Real dst[]) const = 0;
127  virtual void shift(const concepts::Real3d& z, const concepts::Cmplx src[],
128  concepts::Cmplx dst[]) const = 0;
135  virtual void apply(const XYColExpPtr* XY, const F src[],
136  F dst[]) const = 0;
137  };
138 
139  // *************************************************************** FColExp **
140 
143  class FColExp {
144  friend std::ostream& operator<<(std::ostream& os, const FColExp& f);
145  public:
146  virtual ~FColExp() {}
147  virtual uint memory(uint blksz) const = 0;
148  virtual void info(std::ostream& os, uint) const { os << "FColExp()"; }
149  };
150 
151  // ***************************************************************** FColF **
152 
155  template <class F = concepts::Real>
156  class FColF : public FColExp {
157  public:
158  inline FColF(uint blksz) {this->val_ = new F[blksz];}
159  inline ~FColF() {delete[] this->val_;}
160 
161  inline F* value() const {return this->val_;}
162  uint memory(uint blksz) const {
163  return sizeof(FColF<F>) + blksz * sizeof(F);
164  }
165  void info(std::ostream& os, uint blksz) const {
166  for(uint i = 0; i < blksz-1; i++) os << this->val_[i] << ", ";
167  os << this->val_[blksz-1];
168  }
169 
170  private:
171  F* val_;
172  };
173 
174  // ************************************************************** typedefs **
175 
177 
178  // ************************************************************ ExpansionF **
179 
184  template <class Fspc = concepts::Real>
185  class ExpansionF {
186  public:
187  virtual ~ExpansionF() {}
188 
192  virtual uint blksz(uint m) const = 0;
194  virtual uint m() const = 0;
197  virtual FColExp* getCol(uint blksz) const = 0;
204  virtual void evaluate(uint m, const concepts::Real3d& z,
205  FColExp* Fexp) const = 0;
213  virtual void apply(uint m, const FColExp* Fexp, const Fspc src[],
214  Fspc dst[]) const = 0;
215  };
216 
217 } // namespace cluster
218 
219 #endif // expansion_hh
virtual void evaluate(const concepts::Element< F > &elm, const concepts::Real3d &c, XYColExpPtr *XY[]) const =0
Computation of the expansion coefficients.
FColF(uint blksz)
Definition: expansion.hh:158
virtual void operator+=(uint i)=0
An abstract class for an element of a space.
Definition: exceptions.hh:15
virtual ~FColExp()
Definition: expansion.hh:146
virtual uint blksz(uint m) const =0
Size of memory used for the expansion.
void operator+=(uint i)
Definition: expansion.hh:34
virtual FColExp * getCol(uint blksz) const =0
Allocates memory for the expansion coefficients.
XYColF< concepts::Real > XYColReal
Definition: expansion.hh:89
Class to hold expansion coefficients of type F.
Definition: expansion.hh:156
F * value() const
Definition: expansion.hh:161
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
Base class for exceptions.
Definition: exceptions.hh:86
XYColFPtr< F > * operator[](uint i) const
Definition: expansion.hh:70
XYColF(uint blksz, uint n)
Definition: expansion.hh:64
virtual uint blksz() const =0
Size of memory used for the expansion.
friend std::ostream & operator<<(std::ostream &os, const FColExp &f)
void operator-=(uint i)
Definition: expansion.hh:77
virtual ~ExpansionF()
Definition: expansion.hh:187
virtual void apply(const XYColExpPtr *XY, const F src[], F dst[]) const =0
Application of the expansion.
virtual void evaluate(uint m, const concepts::Real3d &z, FColExp *Fexp) const =0
Computation of the expansion coefficients.
virtual void apply(uint m, const FColExp *Fexp, const Fspc src[], Fspc dst[]) const =0
Application of the expansion.
virtual uint m() const =0
Order of the expansion.
virtual void operator-=(uint i)=0
void operator-=(uint i)
Definition: expansion.hh:35
XYColFPtr< F > ColPtr
Definition: expansion.hh:62
virtual ~XYColExp()
Definition: expansion.hh:49
virtual XYColExp * getCol(uint blksz, uint n) const =0
Allocates memory for the expansion coefficients and sets it to zero.
virtual uint memory() const =0
XYColFPtr< concepts::Real > XYColRealPtr
Definition: expansion.hh:88
Abstract class to hold the expansion coefficients.
Definition: expansion.hh:47
virtual ~ExpansionXY()
Definition: expansion.hh:100
void operator+=(uint i)
Definition: expansion.hh:74
Abstract class for the and the part of a kernel expansion.
Definition: expansion.hh:98
virtual XYColExpPtr * operator[](uint i) const =0
FColF< concepts::Real > FColReal
Definition: expansion.hh:176
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
Used for the cluster classes for the boundary element method.
Definition: cebysev.hh:13
Abstract class for the part of a kernel expansion.
Definition: expansion.hh:185
virtual void shift(const concepts::Real3d &z, const concepts::Cmplx src[], concepts::Cmplx dst[]) const =0
virtual void info(std::ostream &os, uint) const
Definition: expansion.hh:148
uint memory(uint blksz) const
Definition: expansion.hh:162
virtual void shift(const concepts::Real3d &z, const concepts::Real src[], concepts::Real dst[]) const =0
Shifting the expansion.
F * value() const
Definition: expansion.hh:37
virtual uint m() const =0
Order of the expansion.
Class to hold expansion coefficients of type F.
Definition: expansion.hh:60
uint memory() const
Definition: expansion.hh:73
Abstract class for a pointer to the expansion coefficients.
Definition: expansion.hh:18
void info(std::ostream &os, uint blksz) const
Definition: expansion.hh:165
Class for a pointer to expansion coefficients of type F.
Definition: expansion.hh:29
virtual uint memory(uint blksz) const =0
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Abstract class to hold the expansion coefficients.
Definition: expansion.hh:143
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich