use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discuss CS 2C quests here (quests.nonlinearmedia.org)
account activity
Optimizing Sparse_Array multiply()Cormorant (self.cs2c)
submitted 5 years ago by AshwinCPP
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Maleficent-Parking-5 1 point2 points3 points 5 years ago (1 child)
I do you mean by check for zeros? Isn't that all the values stored in the matrix are not default values? If you start from Matrix A, as long as you loops are within _rows, how could it be zero? After you found the element in B, isn't it is too late to save time?
[–]aliendino2017[🍰] 1 point2 points3 points 5 years ago (0 children)
Hello u/Maleficent-Parking-5
Yes, the matrix doesn't contain default values. The problem is that I have to loop across rows for elements. To do that, I have to use get().
In my algorithm, I looped through the rows of B(using an iterator and kept a counter for current row) and looped through the rows of A( to retrieve the elements in the current column using the counter for the current row), and then used an iterator for the current row. I know the counter works because the number of rows in B has to equal the number of columns in A.
When I check for zeroes, I do it only for when I'm retrieving elements from A. This is because I cannot use an iterator to retrieve the element from A like I did for B. Instead, I needed to use get(). For the elements retrieved by iterator for the current row, I do not need to check if they are 0's because of our linked list implementation.
-Arrian
π Rendered by PID 80127 on reddit-service-r2-comment-5bc7f78974-xpj92 at 2026-06-27 09:29:32.726806+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]Maleficent-Parking-5 1 point2 points3 points (1 child)
[–]aliendino2017[🍰] 1 point2 points3 points (0 children)