Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

Matrix Multiplication C++

OpenStudy (anonymous):

There seems to be some logical error here, and i am not able to really understand the following part. Code: http://ideone.com/wgZ3J And the part followed by //mult there.

OpenStudy (anonymous):

the page you linked shows up empty for me; on Firefox

OpenStudy (farmdawgnation):

Ditto to the above comment.

OpenStudy (anonymous):

My bad, fixed it, http://ideone.com/wgZ3J

OpenStudy (anonymous):

http://ideone.com/mQNtH lets have a look at before the entire "mult" block...

OpenStudy (anonymous):

http://ideone.com/si08f there now it's better. Instead of the cin >> m >> n; I used cin >> m; and the n = m; same for the o and p. Let's uncomment that mult block. http://ideone.com/EYFhR everything seems fine now.

OpenStudy (anonymous):

Yes but that would just multiply sqare matrices. I want it for normal multiplication, and want to know exactly what happens (inside) with those three loops.

OpenStudy (anonymous):

But thanks for alteast caring about it @agdgdgdgwngo btw, in void print_matrix(int m[10][10], int s) what is int s for?

OpenStudy (anonymous):

Ahh I thought you only needed square matrices :-P the s in the print_matrix procedure specifies the size of the square matrix. I've now modified the print_matrix procedure so it works on row and column dimensions. http://ideone.com/ktBnc the first and second loops in main() just fill up the first and second matrices with input from cin the last loop does the dot product of two matrices

OpenStudy (anonymous):

Wow! Its on a roll now! Sorry to trouble you so much, one last thing, what is the role of m and o in print_matrix(mult, m, o); if its for size as before, then shouldnt it be m,p? And for "for(int k=0;k<n;k++)" am i correct in saying, that the previous loops assign the locations of rows and colums (m and p respectively) and this one multiplies the their values? If that is what you mean by dot product.

OpenStudy (anonymous):

Right; it should be print_matrix(mult, m, p); my bad :-P Right about the for loop as well: that particular one one is computing the matrix product.

OpenStudy (anonymous):

Thank you very much!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!