ug4
matrixrow.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Author: Martin Rupp
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__UG__CPU_ALGEBRA__MATRIXROW__
34 #define __H__UG__CPU_ALGEBRA__MATRIXROW__
35 
36 namespace ug{
38 
39 /*template<typename TValue, typename TIterator>
40 class AlgebraicConnectionIterator : public TIterator
41 {
42  using TIterator::operator *;
43 public:
44  AlgebraicConnectionIterator(TIterator &it) : TIterator(it) {}
45  TValue &value() { check(); return (operator*()).value(); }
46  size_t index() const { check(); return (operator*()).index(); }
47 };
48 template<typename TValue, typename TIterator>
49 class ConstAlgebraicConnectionIterator : public TIterator
50 {
51  using TIterator::operator *;
52 public:
53  AlgebraicConnectionIterator(TIterator &it) : TIterator(it) {}
54  const TValue &value() { check(); return (operator*()).value(); }
55  size_t index() const { check(); return (operator*()).index(); }
56 };*/
57 
58 
61 
62 
63 template<typename TMatrix>
64 class MatrixRow
65 {
66  TMatrix &A;
67  size_t r;
68 public:
69  typedef typename TMatrix::row_iterator iterator;
70  typedef typename TMatrix::const_row_iterator const_iterator;
71  typedef typename TMatrix::value_type value_type;
72  MatrixRow(TMatrix &_A, size_t _r) : A(_A), r(_r)
73  {
74  }
76  {
77  return A.begin_row(r);
78  }
80  {
81  return A.end_row(r);
82  }
83  iterator begin() const
84  {
85  return A.begin_row(r);
86  }
87  iterator end() const
88  {
89  return A.end_row(r);
90  }
91 
93  {
94  return A(r, c);
95  }
96 
97  value_type &operator()(size_t c) const
98  {
99  return A(r, c);
100  }
101  bool has_connection(size_t c) const
102  {
103  return A.has_connection(r, c);
104  }
105 
106  size_t size() const
107  {
108  return A.num_cols();
109  }
110  size_t num_connections() const
111  {
112  return A.num_connections(r);
113  }
114 };
115 
116 template<typename TMatrix>
118 {
119  const TMatrix &A;
120  size_t r;
121 public:
122  typedef typename TMatrix::const_row_iterator const_iterator;
123  typedef typename TMatrix::value_type value_type;
124  ConstMatrixRow(const TMatrix &_A, size_t _r) : A(_A), r(_r)
125  {
126  }
128  {
129  return A.begin_row(r);
130  }
132  {
133  return A.end_row(r);
134  }
135 
136  const value_type &operator()(size_t c) const
137  {
138  return A(r, c);
139  }
141  {
142  return A(r, c);
143  }
144  bool has_connection(size_t c) const
145  {
146  return A.has_connection(r, c);
147  }
148 
149  size_t num_connections() const
150  {
151  return A.num_connections(r);
152  }
153  size_t size() const
154  {
155  return A.num_cols();
156  }
157 };
158 
159 
160 
161 // end group cpu_algebra
163 
164 } // namespace ug
165 
166 
167 
168 #endif
Definition: matrixrow.h:118
value_type & operator()(size_t c)
Definition: matrixrow.h:140
size_t r
Definition: matrixrow.h:120
TMatrix::const_row_iterator const_iterator
Definition: matrixrow.h:122
const value_type & operator()(size_t c) const
Definition: matrixrow.h:136
const_iterator begin() const
Definition: matrixrow.h:127
const_iterator end() const
Definition: matrixrow.h:131
size_t num_connections() const
Definition: matrixrow.h:149
size_t size() const
Definition: matrixrow.h:153
TMatrix::value_type value_type
Definition: matrixrow.h:123
ConstMatrixRow(const TMatrix &_A, size_t _r)
Definition: matrixrow.h:124
const TMatrix & A
Definition: matrixrow.h:119
bool has_connection(size_t c) const
Definition: matrixrow.h:144
Definition: matrixrow.h:65
TMatrix::const_row_iterator const_iterator
Definition: matrixrow.h:70
iterator end() const
Definition: matrixrow.h:87
size_t num_connections() const
Definition: matrixrow.h:110
iterator begin() const
Definition: matrixrow.h:83
TMatrix::row_iterator iterator
Definition: matrixrow.h:69
TMatrix & A
Definition: matrixrow.h:66
size_t size() const
Definition: matrixrow.h:106
value_type & operator()(size_t c)
Definition: matrixrow.h:92
bool has_connection(size_t c) const
Definition: matrixrow.h:101
MatrixRow(TMatrix &_A, size_t _r)
Definition: matrixrow.h:72
iterator begin()
Definition: matrixrow.h:75
iterator end()
Definition: matrixrow.h:79
value_type & operator()(size_t c) const
Definition: matrixrow.h:97
size_t r
Definition: matrixrow.h:67
TMatrix::value_type value_type
Definition: matrixrow.h:71
the ug namespace
T value_type
Definition: sparsematrix_interface.h:2