Sparse Matrix stored in compressed storage Vector CSV

I was looking for sparse matrix storage when I've found this paper (http://dergiler.ankara.edu.tr/dergiler/29/1520/16736.pdf) in which (never seen before) a method named Compressed Sparse Vector is presented ! looks very interesting and I want to figure out how to using it .. , the storage way is detailed explain, but i don't have idea how from this storage i can back into the original matrix .. for example for compute a product , or print out the whole matrix .. I would like to write a function of the CSVmatrix class named findindex(i,j) that return a value if in the original matrix the elenent is non-zero , otherwise return zero ! could you help me with the algorithm?

i wrote only the constructor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
template <typename T>
constexpr CSVmatrix<T>::CSVmatrix(std::initializer_list<std::initializer_list<T>> row) noexcept 
{
      this->rows = row.size()    ;
      auto it    = *(row.begin());
      this->cols = it.size()     ;
      
      iType i=0 , j=0;      
      for(auto& r : row)
      {
         for(auto& c : r)
         {  
            i++ ;
            if( c != 0 )
            {
               aa_.push_back(c);   
               ia_.push_back(i);   
               i=0;
            }
         }
            
      }
}


that for a given matrix
1
2
CSVmatrix<int> csvm1 = {{1,0,0,2,0},{3,4,0,5,0},{6,0,7,8,9},{0,0,10,11,0},{0,0,0,0,12}};    
 
give me the same result of the paper
not sure exactly what this is doing. I always just stored row/column/value format, where row and column are the smallest int that can be used for the dimensions of your data (for me that was usually a single byte, but that is pretty small by today's standards). Depending on the size of the data and all that, you can either store these in a map or a vector and search accordingly to determine if it is there or not or to rebuild the original.

Do you NEED to do it the way the paper did? It looks overly complicated, probably to solve some specific issue (I am sure he had a reason, it just looks over-cooked for most uses).
Last edited on
well I don't know if they have or not specific case ... they said that it's a commonly and convenient method .. for example .. respect to Modified sparse row algorithms , looks easy ! did not ? let me know what you think about modified compress storage row
there has to be some performance gain that I am not seeing 'at a glance'.
Topic archived. No new replies allowed.