ViennaCL - The Vienna Computing Library: viennacl/linalg/detail/spai/sparse_vector.hpp Source File

ViennaCL - The Vienna Computing Library 1.7.1 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2016, 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>
50 class sparse_vector
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
56 sparse_vector() {}
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
viennacl::linalg::detail::spai::sparse_vector::sparse_vector
sparse_vector()
Definition: sparse_vector.hpp:56
viennacl::linalg::detail::spai::sparse_vector::const_iterator
std::map< unsigned int, NumericT >::const_iterator const_iterator
Definition: sparse_vector.hpp:54
viennacl::linalg::detail::spai::sparse_vector::begin
iterator begin()
Definition: sparse_vector.hpp:71
viennacl::linalg::detail::spai::sparse_vector::end
iterator end()
Definition: sparse_vector.hpp:73
viennacl::linalg::detail::spai::sparse_vector::iterator
std::map< unsigned int, NumericT >::iterator iterator
Definition: sparse_vector.hpp:53
NumericT
float NumericT
Definition: bisect.cpp:40
viennacl::linalg::detail::spai::sparse_vector::operator[]
NumericT & operator[](unsigned int ind)
Set the index of the vector in the original matrix.
Definition: sparse_vector.hpp:63
viennacl::linalg::detail::spai::sparse_vector::begin
const_iterator begin() const
Definition: sparse_vector.hpp:70
viennacl::linalg::detail::spai::sparse_vector::find
iterator find(unsigned int var)
Definition: sparse_vector.hpp:68
viennacl::linalg::detail::spai::sparse_vector
Represents a sparse vector based on std::map
Definition: sparse_vector.hpp:50
viennacl::linalg::detail::spai::sparse_vector::clear
void clear()
Definition: sparse_vector.hpp:65
viennacl::linalg::detail::spai::sparse_vector::end
const_iterator end() const
Definition: sparse_vector.hpp:72
viennacl::linalg::detail::spai::sparse_vector::find
const_iterator find(unsigned int var) const
Definition: sparse_vector.hpp:67