Gaussian Elimination

This is a discussion on Gaussian Elimination within the C Programming forums, part of the General Programming Boards category; I am currently working on a huge satellite project that requires at one point a gaussian elimination of matricies in ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Gaussian Elimination

    I am currently working on a huge satellite project that requires at one point a gaussian elimination of matricies in the formulas. I am working mainly in C in my current areas (but I have been trained only in C++). I need to write a paralell version of this algorithm (which I also have been trained in), but would like to get an efficient C serial version first. Can anyone help me out? I don't need the whole block below to understand whats going on, I am just really unclear on C syntax with multidimensional matricies (the whole block was posted for clarity). As a note, the block is only for forward-tracking in the algorithm ... I can write the back-substitution from any help you can give me on this current pseudocode block. Thanks in advance.

    Code:
    // Read n from command line - function output arguements
    // A is of size n by n
    procedure GAUSSIAN_ELIMINATION()
    begin
          GET A, b FROM GIVEN FUNCTIONS
    
    // Forward tracking
          for k := 0 to n-1 do
          begin
                for j := k+1 to n-1 do
                begin
                      A[k,j] := A[k,j]/A[k,k];
                endfor;
                b[k] := b[k]/A[k,k];
                A[k,k] := 1;
                for i := k+1 to n-1 do
                begin
                      for j := k+1 to n-1 do
                      begin
                            A[i,j] := A[i,j] - A[i,k] * A[k,j];
                      endfor;
                      b[i] := b[i] - A[i,k] * b[k];
                      A[i, k] := 0;
                endfor;
          endfor;

  2. #2
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    Well, this is my take on the procedure :-)
    Code:
    void GAUSSIAN_ELIMINATION(void)
      /* Assume A[][] and b[] are global for simplicity */
    {
      int k, j, i;
    
      for (k = 0; k < n-1; k++)
      {
        for (j = k+1; k < n-1; k++)
        {
          A[k][j] /= A[k][k];
        }
    
        b[k] /= A[k][k];
        A[k][k] = 1;
    
        for (i = k+1; i < n-1; i++)
        {
          for (j = k+1; j < n-1; j++)
          {
            A[i][j] /= A[i][k] * A[k][j];
          }
    
          b[i] -= A[i][k] * b[k];
          A[i][k] = 0;
        }
      }
    }
    *Cela*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 07-30-2008, 10:45 AM
  2. Backward substitution in gaussian elimination
    By Meander14 in forum C Programming
    Replies: 0
    Last Post: 09-30-2007, 07:02 AM
  3. Gaussian elimination in C
    By Meander14 in forum C Programming
    Replies: 2
    Last Post: 09-26-2007, 03:43 AM
  4. my gaussian elimination problem
    By utoots in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2003, 10:04 PM
  5. Gaussian Elimination Problem
    By Inexorable in forum C Programming
    Replies: 1
    Last Post: 11-08-2002, 01:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21