![]() |
Multiplication of 2 Matrix in C
On 15th October, 2006
|
Recent Articles
Similar Articles
The output to the Matrix multiplication will be generated as follows. Code:
a11 a12 a13 A11 A12 A13 a11xA11+a12xA21+a13xA31 a11xA12+a12xA22+a13xA32 a21 a22 a23 x A21 A22 A23 = a21xA11+a22xA21+a23xA31 a21xA12+a22xA22+a23xA32 a31 a32 a33 A31 A32 A33 a31xA11+a32xA21+a33xA31 The Code Code: C
|
|
|
#2 |
|
Newbie Member
Join Date: May 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Multiplication of 2 Matrix in C
I'm a student and I've got to realize matrix multiplication using threads. I know how to do it without threads, but with threads it seems to me a little confusing, cause I haven't used threads.
|
|
|
|
|
|
#3 |
|
Pro contributor
![]() Join Date: Jan 2008
Location: Bangalore
Posts: 352
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 3 ![]() ![]() |
Re: Multiplication of 2 Matrix in C
If you are user of Visual Studio (VC8) then you can easily use this Code:
#include<omp.h>
omp_set_num_threads(2 or 4 or 6) // as depends on your loop
#pragma omp parallel for shared(mult, r1,c2) private(j,k)
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
mult[i][j]=0;
for(k=0;k<r1;k++)
{
mult[i][j]+=m1[i][k]*m2[k][j];
/*mult[0][0]=m1[0][0]*m2[0][0]+m1[0][1]*m2[1][0]+m1[0][2]*m2[2][0];*/
}
//printf("%d\t",mult[i][j]);
}
//printf("\n");
}
By the use of OpenMP, parallel computing will be done. Today Google is using OpenMP, MPI, Grid Computing.
__________________
Asadullah Ansari (Trueth Can'nt Be Changed that is Only One In The World "Death" ) |
|
|
|
![]() |
|
| Currently Active Users Reading This Article: 1 (0 members and 1 guests) | |
| Article Tools | Search this Article |
| Display Modes | |
| Bookmarks | |
|
|
|
||||||||||||||||||||||||||||||||