I'm working in LU Decomposition in C.My code is very simple
Algorithm can be parallelized using two loops one for updating lower triangular matrix and one for
updating upper triangular matrix ,but it seems I miss understand something :(
//////////////////////////////////////////////////////////////////////////////
//Those loops have to execute in parallel.//
for (i=0 ; i<N ; i++){
A[i][i]=1;
for (j=i+1 ;j<N ;j++){
L[j][i] = A[j][i]/A[i][i]; //*Update L*//
}
for (j=i+1;j<N;j++){
for(k=i+1 ;k<N;k++){
A[j][k] = A[j][k] - A[i][k] * U[j][i];//*Update U*//
}
}
}
/////////////////////////////////////////////////////////////////////////
//******** Displaying LU matrix**********//
printf("\n Matrix after L transformation: \n");
for(i=0;i<=N;i++)
{
for(j=0;j<=N;j++)
printf("%6.0f\t",L[i][j]);
printf("\n");
}
printf("\n");
for(i=0;i<=N;i++)
{
for(j=0;j<=N;j++)
printf("%6.0f\t",U[i][j]);
printf("\n");
}
This is what I should to get ?! what I'm doing wrong
L =
1.0000 0 0 0 0
0.2000 1.0000 0 0 0
0.2000 0.1667 1.0000 0 0
0.2000 0.1667 0.1429 1.0000 0
0.2000 0.1667 0.1429 0.1250 1.0000
U =
50.0000 10.0000 10.0000 10.0000 10.0000
0 48.0000 8.0000 8.0000 8.0000
0 0 46.6667 6.6667 6.6667
0 0 0 45.7143 5.7143
0 0 0 0 45.0000
but what I got is
Source Matrix :
50 10 10 10 10
10 50 10 10 10
10 10 50 10 10
10 10 10 50 10
10 10 10 10 50
Matrix after L transformation:
0 0 0 0 0 10
10 0 0 0 0 10
10 10 0 0 0 10
10 10 10 0 0 10
10 10 10 10 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Thanks
No comments:
Post a Comment