The question is more theoretical. How can the forward and reverse Gauss processes be solved when solving a SLAE in one procedure, that is, it means, in one cycle, in one “pass”?
Once again, I don’t need the entire algorithm. I need only an idea in words with a very brief explanation to it.
Perhaps, try to organize any cycle from n-1 to 0 (well, if the SLAE is nxn), where the coefficients of the matrix will vanish in a magical way, and the solution vector will be considered?
If suddenly someone might need a piece of code that implements these two moves, then here it is:
/// Прямой ход bool gausss( tdouble ** mtx, tdouble * vect ) { tdouble c; for ( int j = 0; j < n; j++ ) { tdouble temp = abs( mtx[j][j] ); int mem = j; максимум for ( int i = j + 1; i < n; i++ ) { // от j+1 if ( temp < abs( mtx[i][j] ) ) { temp = abs( mtx[i][j] ); mem = i; } } if ( temp < eps ) return false; changing( mtx, vect, mem, j ); for ( int i = j + 1; i < n; i++ ) { c = mtx[i][j] / mtx[j][j]; for ( int k = j; k < n; k++ ) { mtx[i][k] -= c * mtx[j][k]; } vect[i] -= c * vect[j]; } } return true; } /// Обратный ход void gausss_reverse( tdouble ** mtx, tdouble * vect, tdouble * sol ) { for ( int i = n - 1; i >= 0; i-- ) { tdouble temp = 0; for ( int j = i + 1; j < n; j++ ) { temp += mtx[i][j] * sol[j]; } sol[i] = (vect[i] - temp) / mtx[i][i]; } }