ViennaCL - The Vienna Computing Library  1.7.0
Free open-source GPU-accelerated linear algebra and solver library.
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-2015, 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 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 
36 
37 namespace viennacl
38 {
39 namespace linalg
40 {
41 namespace detail
42 {
43 namespace spai
44 {
45 
49 template<typename NumericT>
51 {
52 public:
53  typedef typename std::map<unsigned int, NumericT>::iterator iterator;
54  typedef typename std::map<unsigned int, NumericT>::const_iterator const_iterator;
55 
57 
62  //getter
63  NumericT & operator[] (unsigned int ind) { return v_[ind]; }
64 
65  void clear() { v_.clear(); }
66 
67  const_iterator find(unsigned int var) const { return v_.find(var); }
68  iterator find(unsigned int var) { return v_.find(var); }
69 
70  const_iterator begin() const { return v_.begin(); }
71  iterator begin() { return v_.begin(); }
72  const_iterator end() const { return v_.end(); }
73  iterator end() { return v_.end(); }
74 
75 private:
76  unsigned int size_;
77  std::map<unsigned int, NumericT> v_;
78 };
79 
80 }
81 }
82 }
83 }
84 
85 #endif
std::map< unsigned int, NumericT >::const_iterator const_iterator
std::map< unsigned int, NumericT >::iterator iterator
float NumericT
Definition: bisect.cpp:40
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:34
NumericT & operator[](unsigned int ind)
Set the index of the vector in the original matrix.
Definition: blas3.hpp:36
Represents a sparse vector based on std::map
const_iterator find(unsigned int var) const