Class documentation of Concepts

Loading...
Searching...
No Matches
complex.hh
Go to the documentation of this file.
1
7#ifndef complex_hh
8#define complex_hh
9
10#include <complex>
11#include "basis.hh"
12#include "basics/exceptions.hh"
13#include "basics/typedefs.hh"
14
15namespace concepts {
16
17 // ************************************************************* CmplxPart **
18
25 class CmplxPart : public Function<Real> {
26 public:
28 inline CmplxPart(const Function<Cmplx>& fnc) :
29 Function<Real>(fnc.dim()), cfnc_(&fnc), fnc_(0) {}
31 Function<Real>(fnc.dim()), cfnc_(0), fnc_(&fnc) {}
32
35 throw conceptsException(MissingFeature("not implemented"));
36 return *this;
37 }
38 protected:
39 virtual std::ostream& info(std::ostream& os) const;
40 const Function<Cmplx>* cfnc_;
41 Function<Cmplx>* fnc_;
42 };
43
44 // ************************************************************** RealPart **
45
50 class RealPart : public CmplxPart {
51 public:
55
57 virtual Real& operator()(uint i) {
58 conceptsAssert(this->fnc_, Assertion());
59 return *(Real*)&(*this->fnc_)(i);
60 }
62 virtual Real operator()(uint i) const {
63 if (this->fnc_)
64 return std::real((*this->fnc_)(i));
65 return std::real((*this->cfnc_)(i));
66 }
67 protected:
68 virtual std::ostream& info(std::ostream& os) const;
69 };
70
71 // ************************************************************** ImagPart **
72
77 class ImagPart : public CmplxPart {
78 public:
82
84 virtual Real& operator()(uint i) {
85 conceptsAssert(this->fnc_, Assertion());
86 return *((Real*)&(*this->fnc_)(i)+1);
87 }
89 virtual Real operator()(uint i) const {
90 if (this->fnc_)
91 return std::imag((*this->fnc_)(i));
92 return std::imag((*this->cfnc_)(i));
93 }
94 protected:
95 virtual std::ostream& info(std::ostream& os) const;
96 };
97
98 // ******************************************************* ComplexFunction **
99
104 class ComplexFunction : public Function<Cmplx> {
105 public:
108 Function<Cmplx>(fnc.dim()), cfnc_(fnc) {}
111 throw conceptsException(MissingFeature("not assignable"));
112 return *this;
113 }
114
116 virtual Cmplx& operator()(uint i) {
117 throw conceptsException(MissingFeature("not assignable"));
118 return dummy_;
119 }
121 virtual Cmplx operator()(uint i) const {
122 return cfnc_(i);
123 }
124 protected:
125 virtual std::ostream& info(std::ostream& os) const;
126 private:
127 const Function<Real>& cfnc_;
128 Cmplx dummy_;
129 };
130
131} // namespace concepts
132
133#endif // complex_hh
#define conceptsException(exc)
virtual Function< Real > & operator=(const Function< Real > &fnc)
Assignment operator.
Definition complex.hh:34
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
CmplxPart(const Function< Cmplx > &fnc)
Constructor.
Definition complex.hh:28
virtual Cmplx & operator()(uint i)
Index operator.
Definition complex.hh:116
ComplexFunction(const Function< Real > &fnc)
Constructor.
Definition complex.hh:107
virtual Cmplx operator()(uint i) const
Index operator.
Definition complex.hh:121
virtual Function< Cmplx > & operator=(const Function< Cmplx > &fnc)
Assignment operator.
Definition complex.hh:110
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
uint dim() const
Returns the dimension of the function.
Definition basis.hh:53
virtual Real operator()(uint i) const
Index operator.
Definition complex.hh:89
ImagPart(const Function< Cmplx > &fnc)
Constructor.
Definition complex.hh:80
virtual Real & operator()(uint i)
Index operator.
Definition complex.hh:84
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
RealPart(const Function< Cmplx > &fnc)
Constructor.
Definition complex.hh:53
virtual Real operator()(uint i) const
Index operator.
Definition complex.hh:62
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual Real & operator()(uint i)
Index operator.
Definition complex.hh:57
#define conceptsAssert(cond, exc)
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition typedefs.hh:42