Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matrix Multiplication 1

Status
Not open for further replies.

kalaiarasi

Programmer
Feb 6, 2002
7
MY
Hi all,

Is there any predefined function in VC to do matrix multiplication?

I have 2 2-D arrays and i would like to perform matrix multiplication between these 2 arrays.

Any easier way?

Help.

Kalai
 
kalaiarasi,

i can't think of any predefined functions in vc++....

bu it can be done easily.... suppose u have two 2d arrays like this

int mat1[10][10],mat2[10][10]...

the following code will multiply mat1 and mat2 and store the result in result[10][10]

for(i=0;i<row1;i++)
{
for(j=0;j<col2;j++)
{
result[j]=0;
for(ip=0;ip<col1;ip++)
{
result[j]=result[j]+mat1[ip]*mat2[ip][j];
}
}
}

where row1,col1 is no of rows & colums in mat1 and col2 is no of columns in mat2...

but make sure that column of mat1 is equal to the row of mat2.... if that is not the case u can't multiply the given two matrices...

regards

sridharan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top