Class documentation of Concepts

Loading...
Searching...
No Matches
subVector.hh
Go to the documentation of this file.
1
6#ifndef subvector_hh
7#define subvector_hh
8
9#include "vector.hh"
10#include "space/spaceSet.hh"
11#include "toolbox/set.hh"
12
13namespace concepts {
14
15 // ************************************************************* SubVector **
16
27 template<class F>
28 class SubVector : public Function<F> {
29 public:
31 SubVector(Vector<F>& f, const Set<IndexRange>& indices);
32 SubVector(const Vector<F>& f, const Set<IndexRange>& indices);
33
34 virtual ~SubVector() {}
35
37
38 /* Assignement operator from different number type
39
40 This is extra, because virtual member templates don't exist.
41
42 The compiler checks, if the assigment is possible, e.g.
43 Cmplx = Real, possible
44 Real = Cmplx, not possible
45 */
46 template<class H>
48
51
52 virtual F& operator()(uint i) {
53 conceptsAssert3(i < this->dim_, Assertion(), "i = " << i << ", n = " << this->dim_);
55 return (*v_)(indices_[i]); }
56 virtual F operator()(uint i) const {
57 conceptsAssert3(i < this->dim_, Assertion(), "i = " << i << ", n = " << this->dim_);
58 if (v_)
59 return (*v_)(indices_[i]);
60 return (*vc_)(indices_[i]);
61 }
62
65 virtual Function<F>& operator+=(F c);
66
69 virtual Function<F>& operator-=(F c);
70
72
73 virtual Function<F>& add(const Function<F>& fnc, F sc);
74
76 uint n() const { return this->dim_; }
77 protected:
78 virtual std::ostream& info(std::ostream& os) const;
79 private:
81 Vector<F>* v_;
83 const Vector<F>* vc_;
85 const Set<IndexRange> indices_;
86 };
87
88 template<class F>
89 template<class H>
92 uint j = 0;
93 for (Set<IndexRange>::index_iterator i = indices_.index_begin();
94 i != indices_.index_end(); )
95 (*v_)(i++) = fnc(j++);
96 return *this;
97 }
98
99} // namespace concepts
100
101#endif // subvector_hh
uint dim_
Dimension of the function (or of the space the function is defined)
Definition basis.hh:57
SubVector(Vector< F > &f, const Set< IndexRange > &indices)
Constructor.
virtual Function< F > & operator-=(F c)
Subtraction operator.
virtual Function< F > & add(const Function< F > &fnc, F sc)
Adds a times fnc to this function.
uint n() const
Elements in the vector.
Definition subVector.hh:76
virtual Function< F > & operator+=(const Function< F > &fnc)
Addition operator.
virtual Function< F > & operator*=(F sc)
Scaling operator.
virtual Function< F > & operator+=(F c)
Addition operator.
virtual F & operator()(uint i)
Index operator.
Definition subVector.hh:52
virtual F operator()(uint i) const
Index operator.
Definition subVector.hh:56
SubVector< F > & operator=(F c)
Assignement operator.
virtual Function< F > & operator-=(const Function< F > &fnc)
Subtraction operator.
virtual Function< F > & operator=(const Function< F > &fnc)
Assignment operator.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
#define conceptsAssert(cond, exc)
#define conceptsAssert3(cond, exc, msg)
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320