You are here:

C++/matrix multiplication coding


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?

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.

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

Joydeep Bhattacharya


All Answers

Answers by Expert:

Ask Experts


Joydeep Bhattacharya


TSR, Socket and Very Complex Mathematical Problem


Worked on many OOP projects with design patterns



Master of Computer Applications

Awards and Honors
Being a proud owner of a website of programming called

Past/Present Clients

©2017 All rights reserved.