MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_TransSparseCOOElementViewIter.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TRANS_SPARSE_COO_ELEMENT_VIEW_ITER_H
43 #define TRANS_SPARSE_COO_ELEMENT_VIEW_ITER_H
44 
45 #include <iterator>
46 
48 
49 namespace AbstractLinAlgPack {
50 
79 template <class T_Iter, class T_IterCat, class T_Indice, class T_ValRef, class T_Diff>
81 public:
84 
94  template <class TT_Iter, class TT_IterCat, class TT_Indice, class TT_ValRef, class TT_Diff>
95  class ElementView {
96  public:
97 
98  // friends
99 
100  friend
101  class TransSparseCOOElementViewIter<TT_Iter,TT_IterCat,TT_Indice,TT_ValRef,TT_Diff>;
102 
103  // typedefs
104 
106  typedef TT_Indice indice_type;
108  typedef TT_ValRef value_ref_type;
109 
112  ElementView(const TT_Iter& iter) : encap_iter_(iter)
113  {}
114 
115  // access functions
116 
118  value_ref_type value() const {
119  return encap_iter_->value();
120  }
121 
123  indice_type row_i() const {
124  return encap_iter_->col_j();
125  }
126 
128  indice_type col_j() const {
129  return encap_iter_->row_i();
130  }
131 
132  private:
133  TT_Iter encap_iter_;// iterator that is manipulated by
134  // the host iterator
135 
136  // not defined and not to be called
137  ElementView();
139  };
140 
141  // Local typedefs
142 
144  typedef ElementView<T_Iter,T_IterCat,T_Indice
145  ,T_ValRef,T_Diff> element_view_type;
147  typedef T_Iter encap_iter_type;
149  typedef TransSparseCOOElementViewIter<T_Iter,T_IterCat
150  ,T_Indice,T_ValRef,T_Diff> iterator_type;
151 
152  // Standard C+ library types for iterators
153 
155  typedef T_IterCat iterator_category;
163  typedef T_Diff difference_type;
165  typedef size_t distance_type;
166 
167  // end Public Types
169 
172 
180  {}
181 
183 
186 
187  // Access
189  return const_cast<element_view_type&>(element_view_);
190  }
192  return const_cast<element_view_type*>(&element_view_);
193  }
196  }
197  // Incrementation
198  // ++itr
201  return *this;
202  }
203  // itr++
205  iterator_type tmp = *this;
206  ++*this;
207  return tmp;
208  }
209  // --itr
212  return *this;
213  }
214  // itr--
216  iterator_type tmp = *this;
217  --*this;
218  return tmp;
219  }
220  // itr + n
223  }
226  }
227  // itr += n
230  return *this;
231  }
232  // itr - n
235  }
238  }
239  // itr -= n
242  return *this;
243  }
244  // distance = itr1 - itr2 (distance between elements)
247  }
248 
250 
254 
255  // <
256  bool operator<(const iterator_type& itr)
257  {
259  }
260  // <=
261  bool operator<=(const iterator_type& itr)
262  {
264  }
265  // >
266  bool operator>(const iterator_type& itr)
267  {
269  }
270  // >=
271  bool operator>=(const iterator_type& itr)
272  {
274  }
275  // ==
276  bool operator==(const iterator_type& itr)
277  {
279  }
280  // !=
281  bool operator!=(const iterator_type& itr)
282  {
284  }
285 
287 
288 private:
290 
291  // not defined and not to be called
293 
294 }; // end class TransSparseCOOElementViewIter
295 
296 // ///////////////////////////////////////////////////////////////////////////////////////
297 // Nonmember functions
298 
299 // Allow distance_type as lhs argument in n + itr
300 
301 //template <class Iter, class Cat, class Indice, class ValRef, class Diff>
302 //inline TransSparseCOOElementViewIter<Iter,Cat,Indice,ValRef,Diff>
303 //operator+(Diff n, TransSparseCOOElementViewIter<Iter,Cat,Indice,ValRef,Diff> itr)
304 //{
305 // return itr + n;
306 //}
307 
308 template <class Iter, class Cat, class Indice, class ValRef, class Diff>
311 {
312  return itr + n;
313 }
314 
315 } // end namespace AbstractLinAlgPack
316 
317 #endif // TRANS_SPARSE_COO_ELEMENT_VIEW_ITER_H
TransSparseCOOElementViewIter(T_Iter itr)
Construct with the iterator of COO elements to transpose.
TransSparseCOOElementViewIter< T_Iter, T_IterCat,T_Indice, T_ValRef, T_Diff > iterator_type
indice_type row_i() const
returns col_j() of the underlying COO element
ElementView< T_Iter, T_IterCat, T_Indice,T_ValRef, T_Diff > element_view_type
Templateded iterator for iterating through a set of COO Matix elements but viewing them in transpose...
Type for the object that is returned for the transpose sparse element.
indice_type col_j() const
returns row_i() of the underlying COO element
TransSparseCOOElementViewIter< Iter, Cat, Indice, ValRef, Diff > operator+(Diff n, const TransSparseCOOElementViewIter< Iter, Cat, Indice, ValRef, Diff > itr)