Class documentation of Concepts

Loading...
Searching...
No Matches
submatrix.hh
Go to the documentation of this file.
1
6#ifndef submatrix_hh
7#define submatrix_hh
8
9#include "matrix.hh"
10#include "matrixMult.hh"
11#include "subMatrixIterator.hh"
12#include "CRS.hh"
13#include "space/spaceSet.hh"
15
16#include <type_traits>
17#include <typeinfo>
18
19namespace concepts {
20
21 // forward declaration
22 template<class F, class G>
23 class SubMatrix;
24
25 template<class F>
26 class SubMatrixN;
27
28
29 // ************************************************************* SubMatrix **
30
39 template<class F>
40 class SubMatrixN : public Matrix<typename F::type>,
41 public CRSConvertable<typename F::type> {
42 public:
43 typedef typename F::type type;
45 typedef typename Realtype<type>::type r_type;
47 typedef typename Cmplxtype<type>::type c_type;
49 typedef typename std::conditional<std::is_same<typename Realtype<F>::type, F>::value ,
50 typename Realtype<F>::type, typename Cmplxtype<F>::type >::type d_type;
51
54
61
62 virtual ~SubMatrixN() {}
63
64 virtual void operator()(const Function<r_type>& fncY,
66 virtual void operator()(const Function<c_type>& fncY,
68
69 virtual void transpMult(const Vector<r_type>& fncY,
71 virtual void transpMult(const Vector<c_type>& fncY,
73
74 template<class H, class I>
75 void multiply(const H& fact, I& dest) const {
77 }
78
80 virtual type operator()(const uint i, const uint j) const;
81 virtual type& operator()(const uint i, const uint j);
82
89
95 uint used() const;
96
98 virtual void convertCRS(type* a, int* asub, int* xa) const;
100 virtual void convertCCS(type* a, int* asub, int* xa) const;
102 virtual void convertIJK(type* , int* , int* ) const;
103
111 template<class H, class I>
112 void addInto(Matrix<H>& dest, const I fact,
113 const uint rowoffset = 0, const uint coloffset = 0) const;
114
116 const Set<IndexRange>& indicesX() const { return indicesX_; }
118 const Set<IndexRange>& indicesY() const { return indicesY_; }
119
121 F& matrix() { return *m_; }
122 const F& matrix() const { return *m_; }
123 protected:
124 virtual std::ostream& info(std::ostream& os) const;
126 const Set<IndexRange> indicesX_, indicesY_;
127 private:
129 F* m_;
130 };
131
132 template<class F>
133 template<class H, class I>
135 const uint rowoffset,
136 const uint coloffset) const {
137 for(const_iterator i = begin(); i != end(); ++i)
138 dest(rowoffset + i.row(), coloffset + i.col()) += fact * *i;
139 }
140
141} // namespace concepts
142
143#endif // submatrix_hh
144
virtual void operator()()
void addInto(Matrix< H > &dest, const I fact, const uint rowoffset=0, const uint coloffset=0) const
Definition submatrix.hh:134
virtual void operator()(const Function< c_type > &fncY, Function< c_type > &fncX)
virtual type & operator()(const uint i, const uint j)
Returns and allows access to entry with indices i and j.
SubMatrixN()
Standard constructor.
virtual type operator()(const uint i, const uint j) const
Index operator.
const Set< IndexRange > indicesX_
Index sets of sub matrix.
Definition submatrix.hh:126
const_iterator end() const
Constant iterator, standing behind last element.
const_iterator begin(uint r=0) const
Constant iterator over the elements, standing at position (0,0)
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.
Definition submatrix.hh:50
F & matrix()
Matrix, which the sub matrix is based on.
Definition submatrix.hh:121
Cmplxtype< type >::type c_type
Complex type of data type.
Definition submatrix.hh:47
iterator begin(uint r=0)
Iterator over the elements, standing at position (0,0)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Realtype< type >::type r_type
Real type of data type.
Definition submatrix.hh:45
SubMatrixN(F &m, const Set< IndexRange > &indicesX, const Set< IndexRange > &indicesY)
Constructor.
virtual void convertCRS(type *a, int *asub, int *xa) const
Converts sub matrix to CRS format.
virtual void convertCCS(type *a, int *asub, int *xa) const
Converts sub matrix to CCS format.
const Set< IndexRange > & indicesX() const
Returns index range for the rows.
Definition submatrix.hh:116
const Set< IndexRange > & indicesY() const
Returns index range for the columns.
Definition submatrix.hh:118
virtual void convertIJK(type *, int *, int *) const
Converts sub matrix to IJK format.
void matrixMultiplyRowSorting(const F &factL, const G &factR, Matrix< H > &dest)
Definition matrixMult.hh:28
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320