Algorithm to matrix product MSR format

Click For Summary
The discussion revolves around implementing a modified sparse row (MSR) matrix in C++ and optimizing the product of two MSR matrices. The user has shared their matrix constructor code but is seeking advice on improving computational efficiency for matrix multiplication. There is a mention of a broken link related to MSR matrices, which was corrected by another participant. Additionally, a reminder is given that users should share their attempts or thoughts when asking for help in a homework forum. The focus remains on enhancing the performance of matrix operations in the given implementation.
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.
 
Thread 'Correct statement about size of wire to produce larger extension'
The answer is (B) but I don't really understand why. Based on formula of Young Modulus: $$x=\frac{FL}{AE}$$ The second wire made of the same material so it means they have same Young Modulus. Larger extension means larger value of ##x## so to get larger value of ##x## we can increase ##F## and ##L## and decrease ##A## I am not sure whether there is change in ##F## for first and second wire so I will just assume ##F## does not change. It leaves (B) and (C) as possible options so why is (C)...