2 Replies - 19439 Views - Last Post: 21 June 2010 - 04:16 AM Rate Topic: -----

#1 coolghuy12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 11-January 10

On LU Decomposition in C Program

Posted 20 June 2010 - 09:57 PM

Hi experts.

I was writing a C program on LU Decomposition.
As a start, I was able to do the following for the library file:

a is the matrix, n means the matrix a is n by n, dont mind b and c yet. :)
int LU(double ** a, int n,
       double ** b, double **c)
{
       double p;
       int i, j;
       for(i=1; i < n; i++){
                if( a[i][0] !=0 )
                {
                    p = a[i][0];
                    for(j=0; j < n; j++){
                             a[i][j] = a[i][j]  - p*(a[0][j]/a[0][0]);
                             }
                }
                }         
       return 1;       
}


But the following is only good for the first column of the matrix.
By the way, this screenshot shows the progress of the U MATRIX.
As you can see, this is not yet a complete U Matrix.
How do I expand the function I wrote? Thanks!

Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: On LU Decomposition in C Program

#2 taylorc8  Icon User is offline

  • B&

Reputation: 149
  • View blog
  • Posts: 1,572
  • Joined: 21-July 09

Re: On LU Decomposition in C Program

Posted 21 June 2010 - 03:06 AM

http://en.wikipedia....U_decomposition

I am a bit too stupid to understand the inputs and expected output, but is starting at 1 here intentional?

for(i=1; i < n; i++)



Hey check out the Doolittle algorithm on the wiki too.

This post has been edited by taylorc8: 21 June 2010 - 03:11 AM

Was This Post Helpful? 0
  • +
  • -

#3 coolghuy12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 11-January 10

Re: On LU Decomposition in C Program

Posted 21 June 2010 - 04:16 AM

View Posttaylorc8, on 21 June 2010 - 02:06 AM, said:

I am a bit too stupid to understand the inputs and expected output, but is starting at 1 here intentional?

for(i=1; i < n; i++)



Yes, the first row need not be transformed.
Actually I've figured out the solution a while ago. Thanks!

This post has been edited by coolghuy12: 21 June 2010 - 04:17 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1