ViennaCL - The Vienna Computing Library  1.5.1
sparse_vector.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_DETAIL_SPAI_SPARSE_VECTOR_HPP
2 #define VIENNACL_LINALG_DETAIL_SPAI_SPARSE_VECTOR_HPP
3 
4 /* =========================================================================
5  Copyright (c) 2010-2014, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the PDF manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
27 #include <utility>
28 #include <iostream>
29 #include <fstream>
30 #include <string>
31 #include <algorithm>
32 #include <vector>
33 #include <math.h>
34 #include <map>
35 //local includes
36 //#include <omp.h>
37 
38 
39 namespace viennacl
40 {
41  namespace linalg
42  {
43  namespace detail
44  {
45  namespace spai
46  {
47 
51  template <typename ScalarType>
53  public:
54  typedef typename std::map<unsigned int, ScalarType>::iterator iterator;
55  typedef typename std::map<unsigned int, ScalarType>::const_iterator const_iterator;
57 
61  //getter
62  ScalarType& operator[] (const unsigned int ind){
63  return v_[ind];
64 
65  }
66 
67  void clear(){
68  v_.clear();
69  }
70 
71  const_iterator find(const unsigned int var) const{
72  return v_.find(var);
73  }
74 
75  iterator find(const unsigned int var){
76  return v_.find(var);
77  }
78 
80  return v_.begin();
81  }
82 
84  return v_.end();
85  }
86 
87 
89  return v_.begin();
90  }
91 
93  return v_.end();
94  }
95 
96 
97  private:
98  unsigned int size_;
99  std::map<unsigned int, ScalarType> v_;
100  };
101  }
102  }
103  }
104 }
105 
106 #endif
std::map< unsigned int, ScalarType >::const_iterator const_iterator
Definition: sparse_vector.hpp:55
iterator find(const unsigned int var)
Definition: sparse_vector.hpp:75
const_iterator end() const
Definition: sparse_vector.hpp:83
const_iterator find(const unsigned int var) const
Definition: sparse_vector.hpp:71
Represents sparse vector based on std::map<unsigned int, ScalarType>
Definition: sparse_vector.hpp:52
iterator begin()
Definition: sparse_vector.hpp:88
const_iterator begin() const
Definition: sparse_vector.hpp:79
ScalarType & operator[](const unsigned int ind)
Set the index of the vector in the original matrix May only be called once.
Definition: sparse_vector.hpp:62
void clear()
Definition: sparse_vector.hpp:67
sparse_vector()
Definition: sparse_vector.hpp:56
std::map< unsigned int, ScalarType >::iterator iterator
Definition: sparse_vector.hpp:54
iterator end()
Definition: sparse_vector.hpp:92