Write a C/C++ program that implements (Do not use pivot condensation) Gaussian elimination
method for solving n linear equations in n variables, that calls procedures (5)
(i) Exchange of rows
(ii) lower-triangularisation and
(iii) back substitutions
(Codes of procedures are also to be written)
```cpp
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void exchangeRows(vector<vector<double>>& matrix, int row1, int row2) {
// Swap two rows in the matrix
for (int i = 0; i < matrix[row1].size(); i++) {
swap(matrix[row1][i], matrix[row2][i]);
}
}
void lowerTriangularization(vector<vector<double>>& matrix, int n) {
// Convert the matrix to upper triangular form
for (int i = 0; i < n; i++) {
// Make the pivot element non-zero
if (matrix[i][i] == 0) {
for (int j = i + 1; j < n; j++) {
if (matrix[j][i] != 0) {
exchangeRows(matrix, i, j);
break;
}
}
}
// Make the elements below the pivot zero
for (int j = i + 1; j < n; j++) {
double factor = matrix[j][i] / matrix[i][i];
for (int k = i; k < n + 1; k++) {
matrix[j][k] -= factor * matrix[i][k];
}
}
}
}
void backSubstitution(vector<vector<double>>& matrix, int n, vector<double>& solution) {
// Back substitution to find the solution
for (int i = n - 1; i >= 0; i--) {
____ ___ ______ ____ ________ ____ ____ ________ _________ _____ __________ ___.
_________ ______ ____ _____ __________ _______ _________.
____ _________ _______ __________ _________ ______ ________ ________ _____.
_____ ________ ________ ________ _____.
______ ______ ___ _______ ____ ______ __________ ____ _________.
_____ ______ ___ _________ __________ _______ _______ ___ ______.
_________ ___ ______ __________ __________.
_______ ____ _________ ____ _________.
_____ _______ ____ ______ ___ _____ ____ _____ _____ _____.
_____ _____ _____ ________ _____ _____ _____ __________ __________.
______ ___ __________ ___ ____ ____ __________ ___.
_________ ____ _________ _____ ______ ________ _______ _________ _____ ___ ________.
___ _______ _____ _____ ______ ___ _________ ________ _____ ____ __________ _____.
____ ________ _____ __________ _______ _____.
_______ ____ ________ _________ ____ ______ ___ __________ _______.
___ _____ ___ ________ _____ ______ ______ ________.
___ _______ __________ ________ ____ ________ _______ _________ _______ ________ ___.
____ ________ ___ _______ ___ _____ ___ _______.
____ ____ ____ _____ _________.
________ ________ _________ ___ ________ __________.
_______ ________ ___ _______ _____ __________ _______.
_________ ____ ______ _____ _______ __________ ________ ___ _______ _______ ____ __________.
_________ __________ ____ _____ _________ __________.
_______ _____ ___ ___ _______ ________ ______ ___ ____ ________.
______ _________ _____ _________ ___ __________ __________.
_____ _____ __________ _____ _______ ______ ___ ______ ________ _______.
_________ ___ ________ ________ ____.
______ ___ ____ ___ ___ ________ ___.
__________ _____ _________ _________ ______ _____ ________ _____ ____ ______.
_____ ____ _______ ________ ___ _______ ______.
__________ __________ _____ __________ ___ __________ _____ ___.
___ _________ ____ ______ ________ _______ ________ ________ __________ ___.
_____ ______ _______ ____ _________ _________ ________ ___ _____ _____.
________ _______ _____ __________ _________.
__________ ______ ___ __________ _____ ____ _____ _______ _________ _________ ____ _________.
__________ _________ ___ _____ _____ _________.
_________ _____ ________ ___ ______ _______.
________ ________ ________ ______ ______ _________.
__________ _________ _______ __________ ______ __________ ________ _____.
___ _______ ________ ________ ___ ________ _____ _________ _____ ___ _________.
________ _____ _______ _______ ________ ___ _____ ________ _________ ___ ________.
____ ____ _______ _________ ______ ______ ________ _________.
_______ ___ ______ ____ _______ _______ _______.
____ _________ ______ _________ ________ ____ __________ _____ _______ _____ ________.
___ _______ ___ ______ ______ _________ ________.
____ ____ _______ __________ _____ ____ ________.
_____ ________ ___ _________ ________ ________ __________ _________.
______ ______ _____ ________ ________ _________.
________ _________ _________ _____ _________ __________ _____ _______.
______ _____ ________ __________ _________ ___ ___ _____ ____ _________.
______ __________ _____ ______ ________ _________ _____ _____ ______ _________ ___.
_____ ________ ________ __________ __________ ___ ____ ________ __________ _____ _____.
______ ____ _________ _________ _________ _____ __________ ________.
______ ___ _____ ______ _____ ___.
______ __________ __________ __________ _______ ___.
_______ ____ ___ ____ __________ _______ __________ ____ ___.
___ _______ _______ ______ _________ _________ ______ ____ ______ ___.
__________ ________ ____ ______ _________ ___ __________ ___.
_________ _______ ___ _________ _______ __________ _________ ____ ________ ___ ____ ___.
______ _____ _________ ______ ____ _______ _____ _____.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required