frm_sum.hh

Go to the documentation of this file.
1 
8 #ifndef sumformula_hh
9 #define sumformula_hh
10 
11 #include "basics/typedefs.hh"
12 #include "basics/output.hh"
14 #include "formulaContainer.hh"
15 #include "exceptions.hh"
16 
17 namespace concepts {
18 
19 
20  // ************************************************************ Frm_Sum **
21 
30  template<class F, class H = F, class J = F>
31  class Frm_Sum : public Formula<F> {
32  public:
34  const FormulaContainer<J>& frm2)
35  : frm1_(frm1), frm2_(frm2)
36  {
37  if (frm1.empty()) throw(PointerToEmptyElementFormula());
38  if (frm2.empty()) throw(PointerToEmptyElementFormula());
39  }
40  virtual F operator() (const Real p, const Real t = 0.0) const {
41  return frm1_(p,t) + frm2_(p,t);
42  }
43  virtual F operator() (const Real2d& p, const Real t = 0.0) const {
44  return frm1_(p,t) + frm2_(p,t);
45  }
46  virtual F operator() (const Real3d& p, const Real t = 0.0) const {
47  return frm1_(p,t) + frm2_(p,t);
48  }
49  virtual Frm_Sum<F,H,J>* clone() const {
50  return new Frm_Sum<F,H,J>(frm1_, frm2_);
51  }
52  protected:
53  virtual std::ostream& info(std::ostream& os) const {
54  return os << concepts::typeOf(*this) <<"(" << frm1_ << " + " << frm2_ << ")";
55  }
56  private:
61  };
62 
63 
64  // ************************************************************ operator+ **
65 
76  Frm_Sum<Real> operator+(const Formula<Real>& frm, const Real a);
77 
79 
81 
83 
84  // ************
85 
87 
89 
91 
93 
94 
95 } // namespace concepts
96 
97 
98 #endif // sumformula_hh
virtual F operator()(const Real p, const Real t=0.0) const
Application operator.
Definition: frm_sum.hh:40
const FormulaContainer< H > frm1_
First Formula.
Definition: frm_sum.hh:58
Frm_Sum(const FormulaContainer< H > &frm1, const FormulaContainer< J > &frm2)
Definition: frm_sum.hh:33
Interface for a formula.
Definition: lform.hh:18
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
Class for a sum of formula.
Definition: frm_sum.hh:31
bool empty() const
Returns true if no formula is stored.
virtual Frm_Sum< F, H, J > * clone() const
Definition: frm_sum.hh:49
Frm_Sum< Real > operator+(const Formula< Real > &frm, const Real a)
Simple adding two formulas by +-operator.
virtual std::ostream & info(std::ostream &os) const
Definition: frm_sum.hh:53
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
const FormulaContainer< J > frm2_
Second Formula.
Definition: frm_sum.hh:60
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Exception class to express that the RCP pointer points to 0.
Definition: exceptions.hh:55
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich