Class documentation of Concepts

Loading...
Searching...
No Matches
denseMatrix.hh
Go to the documentation of this file.
1
6#ifndef denseMatrix_hh
7#define denseMatrix_hh
8
9#include "space/element.hh"
10#include "compositions.hh"
11#include "matrix.hh"
12#include <new> // exception handling for function new
13
14#include <type_traits>
15#include <typeinfo>
16
17namespace concepts {
18
19 // forward declaration
20 template<class F>
21 class Space;
22
23 template<class F, class G>
24 class BilinearForm;
25
26 // *********************************************************** DenseMatrix **
27
43 template<class F>
44 class DenseMatrix : public Matrix<F>, public ElementMatrix<F> {
45 public:
47 typedef typename Realtype<F>::type r_type;
49 typedef typename Cmplxtype<F>::type c_type;
51 typedef typename std::conditional<std::is_same<typename Realtype<F>::type, F>::value ,
52 typename Realtype<F>::type, typename Cmplxtype<F>::type >::type d_type;
53
76 template<class G>
78 const BilinearForm<F,G>& bf, const bool single=true);
79
92 template<class G>
93 DenseMatrix(const Space<G>& spc, const BilinearForm<F,G>& bf);
104 template<class G>
106 const Sequence<ElementWithCell<G> * > & seq);
112 template<class G>
114
121 DenseMatrix(int m = 0, int n = 0, bool transpose = false)
122 : Matrix<F>(m, n), ElementMatrix<F>(transpose ? n : m, transpose ? m : n)
123 {
124 if(transpose)
125 this->transpose();
126 }
127
141 DenseMatrix(const Matrix<F>& m, bool t = false);
146 DenseMatrix(const Vector<F>& v, bool t = false);
147
148 virtual void operator()(const Function<r_type>& fncY,
150 virtual void operator()(const Function<c_type>& fncY,
152
153 template<class H, class I>
154 void operator()(const Vector<H>& fncY, Vector<I>& fncX);
155
156 virtual void transpMult(const Vector<r_type>& fncY,
157 Vector<F>& fncX);
158 virtual void transpMult(const Vector<c_type>& fncY,
160
161 virtual F operator()(const uint i, const uint j) const {
163 }
164
165 virtual F& operator()(const uint i, const uint j) {
167 }
168
169 virtual DenseMatrix<F>& operator=(const F& v)
170 {
172 return *this;
173 }
174
178 virtual void resize(uint m, uint n) {
179 ElementMatrix<F>::resize(this->dimX_ = m, this->dimY_ = n);
180 }
181
182 virtual void setTranspose(bool t) {
183 if(this->isTranspose() != t) std::swap(this->dimX_,this->dimY_);
185 }
186
191 void addInto(Matrix<F>& dest, const F fact,
192 const uint rowoffset = 0, const uint coloffset = 0) const;
193
195 template<class T>
196 void addInto(Matrix<T>& dest, const T fact,
197 const uint rowoffset = 0, const uint coloffset = 0) const
198 {
199 conceptsAssert(dest.dimX() >= this->dimX() + rowoffset, Assertion());
200 conceptsAssert3(dest.dimY() >= this->dimY() + coloffset, Assertion(),
201 "dest.dimY() = " << dest.dimY() << ", dimY() = " <<
202 this->dimY() << ", coloffset = " << coloffset);
203 for (uint i = 0; i < this->dimX(); ++i)
204 for (uint j = 0; j < this->dimY(); ++j) {
205 const F a = operator()(i,j);
206 dest(i+rowoffset,j+coloffset) += a*fact;
207 }
208 };
209
211 template<class T>
212 void addIntoT(Matrix<T>& dest, const T fact,
213 const uint rowoffset = 0, const uint coloffset = 0) const {
214 conceptsAssert(dest.dimY() >= this->dimX() + coloffset, Assertion());
215 conceptsAssert3(dest.dimX() >= this->dimY() + rowoffset, Assertion(),
216 "dest.dimY() = " << dest.dimY() << ", dimY() = " <<
217 this->dimY() << ", coloffset = " << coloffset);
218 for (uint i = 0; i < this->dimX(); ++i)
219 for (uint j = 0; j < this->dimY(); ++j) {
220 const F a = operator()(i,j);
221 dest(j+rowoffset,i+coloffset) += a*fact;
222 }
223 };
224
225 protected:
226 virtual std::ostream& info(std::ostream& os) const;
227 };
228
229 template<class F>
230 template<class H, class I>
232 {
235 const F* m = (const F*)this->getData();
236 I* x(fncX);
237 for (uint i = 0; i < ElementMatrix<F>::m(); ++i) {
238 H* y(fncY);
239 I fi = 0.0;
240 for (uint j = 0; j < ElementMatrix<F>::n(); ++j)
241 fi += *m++ * *y++;
242 *x++ = fi;
243 }
244 }
245
246} // namespace concepts
247
248#endif // senseMatrix_hh
DenseMatrix(const Space< G > &spc, const BilinearForm< F, G > &bf, const Sequence< ElementWithCell< G > * > &seq)
DenseMatrix(const Compose< F > &L)
DenseMatrix(const Space< G > &spcX, const Space< G > &spcY)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual F & operator()(const uint i, const uint j)
Returns and allows access to entry with indices i and j.
DenseMatrix(const Vector< F > &v, bool t=false)
DenseMatrix(const Space< G > &spc, const BilinearForm< F, G > &bf)
void addInto(Matrix< F > &dest, const F fact, const uint rowoffset=0, const uint coloffset=0) const
std::conditional< std::is_same< typenameRealtype< F >::type, F >::value, typenameRealtype< F >::type, typenameCmplxtype< F >::type >::type d_type
Data type, depending if F is real or complex.
virtual void operator()(const Function< c_type > &fncY, Function< c_type > &fncX)
virtual void operator()(const Function< r_type > &fncY, Function< F > &fncX)
Computes fncX = A(fncY) where A is this matrix.
DenseMatrix(const LiCo< F > &L)
virtual void transpMult(const Vector< r_type > &fncY, Vector< F > &fncX)
Computes fncX = AT fncY where A is this matrix.
DenseMatrix(const Space< G > &spcX, const Space< G > &spcY, const BilinearForm< F, G > &bf, const bool single=true)
virtual void resize(uint m, uint n)
DenseMatrix(int m=0, int n=0, bool transpose=false)
virtual F operator()(const uint i, const uint j) const
Returns entry with indices i and j.
void addIntoT(Matrix< T > &dest, const T fact, const uint rowoffset=0, const uint coloffset=0) const
DenseMatrix(const Matrix< F > &m, bool t=false)
void addInto(Matrix< T > &dest, const T fact, const uint rowoffset=0, const uint coloffset=0) const
Cmplxtype< F >::type c_type
Complex type of data type.
Realtype< F >::type r_type
Real type of data type.
DenseMatrix(const DenseMatrix< F > &m)
Copy constructor.
uint n() const
Returns the number of columns.
Definition element.hh:153
uint m() const
Returns the number of rows.
Definition element.hh:151
const F & operator()(const uint i, const uint j) const
Returns element (i, j)
Definition element.hh:222
virtual void resize(uint m, uint n)
ElementMatrix< F > & operator=(const ElementMatrixBase< F > &A)
Assignement operator.
void setTranspose(bool t)
Definition element.hh:286
virtual const uint dimY() const
F type
Type of data, e.g. matrix entries.
virtual const uint dimX() const
virtual void operator()()
uint dimX_
Dimension of image space and the source space.
#define conceptsAssert(cond, exc)
#define conceptsAssert3(cond, exc, msg)
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320