lundi 21 décembre 2020

How can I multiply two matrices if I only store non-zero elements in a list

So I got my Data structures and algorithms project. I basically need to develop a class Matrix with following atributes:

  1. list<list<pair<int,double>>> - in which are only non-zero elements of a Matrix, (Value of a certain element is stored as the second argument of a pair, and the first argument of a pair represents an actual column in which that element is located in original Matrix)
  2. vector rows; (rows[i] - represents an actual row for each list in a list of lists above, respectively)
  3. actual number of rows
  4. actual number of columns

In my project so far I have developed specific constructors, adding and substracting matrices etc. The only thing that I am not able to do is multiply two instances of a class Matrix, meaning I am not able to develop an operator* for class Matrix. Does somebody now how can I acomplish that?

Aucun commentaire:

Enregistrer un commentaire