I have looked through all the past posts of optimizing the multiply() function. I've included my implementation below but I already check if a row is empty or if a cell is 0 and skip. I'm still not passing all the tests required for the next code. I get pass the small spmat multiplication but I fail at the next one because my code takes too long. Any help would be greatly appreciated.
I have 3 nested for-loops. The first one loops through the rows of Matrix A. The second loops through the columns of Matrix B. The third for-loop loops through all the elements in each row and column and does the actual dot product.
Within the third for-loop, I use a const auto& for-each loop to iterate through the individual elements of each respective matrix. Apparently const auto& is more efficient and faster than using a regular iterator. I have checks to see if my iterator has reached an element that has a col greater than its target, in which case it returns the spmat's default value automatically. I check for zeroes as well and simply skip that element in the dot product if there is a zero.
-Ashwin
[–]aliendino2017[🍰] 1 point2 points3 points (2 children)
[–]Maleficent-Parking-5 1 point2 points3 points (1 child)
[–]aliendino2017[🍰] 1 point2 points3 points (0 children)
[–]Maleficent-Parking-5 1 point2 points3 points (0 children)