vectorFormula.hh

Go to the documentation of this file.
1 
8 #ifndef vectorformula_hh
9 #define vectorformula_hh
10 
11 #include <vector>
12 #include "toolbox/sharedPointer.hh"
13 #include "elementFormula.hh"
14 
15 namespace concepts {
16 
17 
18  // ********************************************************* VectorFormula **
19 
24  template<typename F, int dim>
25  class VectorFormula : public Formula< Point<F, dim> >
26  {
27  public:
30 
32  {
33  for(int i=0; i < dim; ++i)
34  formulas_.push_back(EntryFormulaRCP());
35  }
36 
41  VectorFormula<F,dim>(const std::vector< EntryFormulaRCP >& formulas)
42  : formulas_(formulas)
43  {
45  }
46 
51  Point<F, dim> operator() (const Real p, const Real t = 0.0) const
52  {
53  Point<F, dim> ret;
54  for (int i=0; i < dim; ++i) {
55  ret[i] = formulas_[i] ? (*formulas_[i])(p, t) : F(0);
56  }
57  return ret;
58  }
59 
60  Point<F, dim> operator() (const Real2d& p, const Real t = 0.0) const
61  {
62  Point<F, dim> ret;
63  for (int i=0; i < dim; ++i) {
64  ret[i] = formulas_[i] ? (*formulas_[i])(p, t) : F(0);
65  }
66  return ret;
67  }
68 
69  Point<F, dim> operator() (const Real3d& p, const Real t = 0.0) const
70  {
71  Point<F, dim> ret;
72  for (int i=0; i < dim; ++i) {
73  ret[i] = formulas_[i] ? (*formulas_[i])(p, t) : F(0);
74  }
75  return ret;
76  }
77 
79  virtual VectorFormula<F,dim>* clone() const
80  {
81  return new VectorFormula<F, dim>(*this);
82  }
83 
84 #if 0
86  : formulas_(other.formulas_)
87  { }
88 #endif
89 
90  virtual ~VectorFormula() { }
91 
92  const std::vector< EntryFormulaRCP >& getFormulas()
93  {
94  return formulas_;
95  }
96 
98  {
100 
101  return formulas_[i];
102  }
103 
104  protected:
105  std::vector< EntryFormulaRCP > formulas_;
106 
107  virtual std::ostream& info(std::ostream& os) const {
108  os << concepts::typeOf(*this) << "([";
109  for (int i=0; i < dim; ++i) {
110  if (formulas_[i])
111  os << *formulas_[i];
112  else
113  os << "0";
114  if (i < dim - 1)
115  os << ", ";
116  }
117  return os << "])";
118  }
119  };
120 
121 
122 } // namespace concepts
123 
124 
125 #endif // vectorformula_hh
EntryFormulaRCP & operator[](int i)
Basic class for a Point or a vector.
Interface for a formula.
Definition: lform.hh:18
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
const std::vector< EntryFormulaRCP > & getFormulas()
Exception class for assertions.
Definition: exceptions.hh:258
Point< F, dim > operator()(const Real p, const Real t=0.0) const
Evaluates the formula.
Element formula returning a vector.
virtual std::ostream & info(std::ostream &os) const
std::vector< EntryFormulaRCP > formulas_
Reference-counting pointer.
Definition: bf_iddiv.hh:15
RCP< const concepts::Formula< F > > EntryFormulaRCP
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
Point< F, dim > value_type
virtual VectorFormula< F, dim > * clone() const
Virtual copy constructor.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
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