Implementing Gaussian Elimination in C++ with Scaled Partial Pivoting

  • Context: C/C++ 
  • Thread starter Thread starter Isma
  • Start date Start date
  • Tags Tags
    C++ Elimination
Click For Summary

Discussion Overview

The discussion revolves around implementing Gaussian elimination in C++ with a focus on scaled partial pivoting. Participants are exploring the logic and steps necessary to develop the program, including matrix operations and algorithmic structure.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant expresses difficulty in understanding the logic behind implementing Gaussian elimination and seeks help without requesting a complete solution.
  • Another participant suggests that the first step should be to articulate the problem clearly in plain English and then develop pseudocode to facilitate coding in C++.
  • A further contribution emphasizes the importance of clarity and precision in the problem description, suggesting that it should be understandable even to a young child.
  • Discussion includes the necessity of using scaled partial pivoting and the implementation of basic matrix operations using 2D arrays, such as row swapping and matrix printing functions.
  • Participants discuss the process of selecting the best pivot row based on the largest relative element in the row when using scaled partial pivoting.
  • There is mention of decomposing the matrix into upper and lower triangular matrices (LU decomposition) and the associated solving techniques using forward and backward substitution, noting that this approach may complicate the implementation but offers performance benefits.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the specific implementation details or the best approach to take, indicating that multiple competing views and methods are being discussed.

Contextual Notes

Participants have not fully resolved the assumptions regarding the matrix operations and the specific requirements for implementing scaled partial pivoting within the Gaussian elimination framework.

Who May Find This Useful

Individuals interested in programming algorithms, particularly in C++, as well as those studying numerical methods or linear algebra may find this discussion relevant.

Isma
Messages
27
Reaction score
0
i m having serious problem regarding this program...i m not asking u 2 make it for me...just help me with logic because i can't get gist of it...pleasezz i need help...i ve working on it like 3 hours nd its like my mind has gone blank:(
 
Technology news on Phys.org
write out in plain english what it is you need to do. then work out a psudo-code for it. after that it should be easy to get it down in C++.
 
But not just any old plain english -- it ought to be clear and precise. I like to say that a young kid should be able to follow your directions to get the right answer!
 
Will you use scaled partial pivoting? You should start by implementing your matrices and basic matrix operations. You can use 2D arrays for your matrices. You'll need basic functions like swapRows(R1, R2) and factorRow(PivotRow, RowToFactor, Multiplier) and printMatrix() for testing.
Then you should create a function that finds the best pivot row, if yu're using Scaled partial pivoting, then you select the row whose first non-zero element is the biggest relative to all the elements in its row.
Finally get down to Gaussian elimination, using the functions you have created.

What technique will you use for solving? Are you going to decompose the matrix into upper and lower triangular matrices?
If you want to solve for X in MX = B where M is a matrix and B is a vector, then you can split M into LU where L is lower triangular and U is upper triangular. Then you'd solve LY=B for Y with forward substitution and finally solve UX=Y for x, with backwards substitution. If you have to do things this way then it's a little more complicated, but you get better performance because your LU matrices are reusable whenever only B changes and M stays the same.
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
81
Views
8K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
27K
  • · Replies 14 ·
Replies
14
Views
6K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 29 ·
Replies
29
Views
10K