You are here:

C++/matrix multiplication coding

Advertisement


Question
Hello, Hope you're doing well.  I am trying to write a  loop program which multiplies inverse of a matrix M1 by matrix M2 twenty times  iterating their variable i from 1 to 20. Each matrix M1 and M2 is a 4*4 matrix whose each  element is a function of r =i*constant
the elements of matrices are in the form of some Besselís functions and quite long.  I decided to store each element under a new name to avoid complications.
I also tried using a for loop similar to
(int i = 1; i <= 20; i++) {
cout << i << endl;
}
int product = 0;
for (int i = 0; i <= 20; i++) {
cout << i << endl;
product function of the matrices goes here;
}
Would this be a reasonable approach?  I tried using Matlab with a simple matrix to be multiplied 20 times and it failed.  Do you have any suggestion for writing a program that can multiply two matrices 20 times with iterating their elements each time?


Answer
Hi Shirin

Write a program that multiplies a n/n matrix with another n/n matrix and put the thing in a loop as you have said which will iterate 20 times.

You can have a look at this link if you have any problem regarding multiplication of matrix.
http://www.scodz.com/ViewProgram.php?uid=2&link=6

Try it once and if you fail do let me know so that I can give you more hints about doing the same.

regards
Joydeep Bhattacharya
http://www.scodz.com

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

TSR, Socket and Very Complex Mathematical Problem

Experience

Worked on many OOP projects with design patterns

Organizations
http://www.scodz.com

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Awards and Honors
Being a proud owner of a website of programming called http://www.scodz.com

Past/Present Clients
http://www.funforu.com http://www.dhoondho.com http://analysingc.50webs.com

©2016 About.com. All rights reserved.