ViennaCL - The Vienna Computing Library  1.5.0
viennacl/linalg/detail/spai/sparse_vector.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_LINALG_DETAIL_SPAI_SPARSE_VECTOR_HPP
00002 #define VIENNACL_LINALG_DETAIL_SPAI_SPARSE_VECTOR_HPP
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2013, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008    Portions of this software are copyright by UChicago Argonne, LLC.
00009 
00010                             -----------------
00011                   ViennaCL - The Vienna Computing Library
00012                             -----------------
00013 
00014    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00015 
00016    (A list of authors and contributors can be found in the PDF manual)
00017 
00018    License:         MIT (X11), see file LICENSE in the base directory
00019 ============================================================================= */
00020 
00027 #include <utility>
00028 #include <iostream>
00029 #include <fstream>
00030 #include <string>
00031 #include <algorithm>
00032 #include <vector>
00033 #include <math.h>
00034 #include <map>
00035 //local includes
00036 //#include <omp.h>
00037 
00038 
00039 namespace viennacl
00040 {
00041   namespace linalg
00042   {
00043     namespace detail
00044     {
00045       namespace spai
00046       {
00047 
00051         template <typename ScalarType>
00052         class sparse_vector{
00053         public:
00054             typedef typename std::map<unsigned int, ScalarType>::iterator iterator;
00055             typedef typename std::map<unsigned int, ScalarType>::const_iterator const_iterator;
00056             sparse_vector() {}
00057 
00061             //getter
00062             ScalarType& operator[] (const unsigned int ind){
00063                 return v_[ind];
00064 
00065             }
00066 
00067             void clear(){
00068                 v_.clear();
00069             }
00070 
00071             const_iterator find(const unsigned int var) const{
00072                 return v_.find(var);
00073             }
00074 
00075             iterator find(const unsigned int var){
00076                 return v_.find(var);
00077             }
00078 
00079             const_iterator begin() const{
00080                 return v_.begin();
00081             }
00082 
00083             const_iterator end() const{
00084                 return v_.end();
00085             }
00086 
00087 
00088             iterator begin(){
00089                 return v_.begin();
00090             }
00091 
00092             iterator end(){
00093                 return v_.end();
00094             }
00095 
00096 
00097         private:
00098             unsigned int size_;
00099             std::map<unsigned int, ScalarType> v_;
00100         };
00101       }
00102     }
00103   }
00104 }
00105 
00106 #endif