Algorithm to matrix product MSR format

Click For Summary

Homework Help Overview

The discussion revolves around implementing a modified sparse row (MSR) matrix in C++ and optimizing the matrix product operation for two MSR matrices. The original poster shares their implementation details and seeks advice on improving computational efficiency.

Discussion Character

  • Exploratory, Assumption checking

Approaches and Questions Raised

  • The original poster describes their current implementation and asks for suggestions on optimizing the matrix product. Some participants question the clarity of the problem and the necessity of providing an attempt or thoughts on the approach.

Discussion Status

The discussion is ongoing, with participants providing feedback on the clarity of the original post and emphasizing the importance of sharing attempts or thoughts. There is no explicit consensus yet, as the focus is on gathering insights and clarifications.

Contextual Notes

Participants note that the original poster's link to additional resources was initially incorrect, which may affect the understanding of the MSR format. There is an expectation for the original poster to provide more context or attempts related to their question.

drudox
Messages
2
Reaction score
0
Hi everybody,
I'm writing some algebra classes in C++ , Now I'm implementing the modified sparse row matrix , I wrote all most all of the class, but I didn't find the way saving computing time to perform the product of two Modified sparse row matrix .. if you don't know it you can read in the link : http://www.iue.tuwien.ac.at/phd/wagner/node83.html

by the way .. the matrix constructor is written as follow :
Code:
template <typename T>
constexpr MCSRmatrix<T>::MCSRmatrix( std::initializer_list<std::initializer_list<T>> rows)
{
      this->dim  = rows.size();
      auto _rows = *(rows.begin());

      aa_.resize(dim+1);
      ja_.resize(dim+1);

      if(dim != _rows.size())
      {
          throw std::runtime_error("Error in costructor! MCSR format require square matrix!");
      }

      itype w = 0 ;
      ja_.at(w) = dim+2 ;
      for(auto ii = rows.begin(), i=1; ii != rows.end() ; ++ii, i++)
      {
          for(auto ij = ii->begin(), j=1, elemCount = 0 ; ij != ii->end() ; ++ij, j++ )  
          {
              if(i==j)
                 aa_[i-1] = *ij ;
              else if( i != j && *ij != 0 )
              {  
                 ja_.push_back(j);
                 aa_.push_back(*ij);
                 elemCount++ ;
              }
              ja_[i] = ja_[i-1] + elemCount;          
          }
      }    
      printMCSR();
}
if you know C++ you got the way the matrix works .. if this question is not well explained please let me know !
 
Last edited:
Physics news on Phys.org
This being a homework forum, you need to post an attempt, or at the least, some thoughts on approaches.