Algorithm to matrix product MSR format

Click For Summary
SUMMARY

The discussion focuses on implementing a Modified Sparse Row (MSR) matrix product in C++ for algebra classes. The user has developed a matrix constructor that initializes the MSR format but seeks optimization techniques to enhance the performance of matrix multiplication. Key components of the implementation include the use of templates, dynamic resizing of arrays, and error handling for non-square matrices. The user also references a specific link for further reading on MSR matrices, emphasizing the need for clarity in their question regarding performance improvements.

PREREQUISITES
  • C++ programming proficiency
  • Understanding of matrix algebra
  • Knowledge of sparse matrix representations
  • Familiarity with performance optimization techniques in C++
NEXT STEPS
  • Research "C++ performance optimization techniques for matrix operations"
  • Explore "Sparse matrix multiplication algorithms"
  • Learn about "C++ templates and their applications in data structures"
  • Investigate "Memory management strategies for large data structures in C++"
USEFUL FOR

Students and developers working on numerical computing, particularly those implementing matrix operations in C++, as well as educators creating algebra-related coursework.

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.