Question
Implement this pseudo code with Java. n is the size of the matrix for an n x n matrix. k points to the pivot. i
Implement this pseudo code with Java.
n is the size of the matrix for an n x n matrix.
k points to the pivot.
i points to the equation being eliminated.
j points to the term you're working with.
Naive Gaussian Elimination
// Forward Elimination
function FwdElimination(coeff : array(n,n), const : vector(n)) for k = 1 to (n - 1) for i = k + 1 to n mult := coeff[i][k] / coeff[k][k] for j <- k + 1 to n coeff[i][j] := coeff[i][j] - mult * coeff[k][j] end for const[i] := const[i] - mult * const[k] end for end for end function
// Back Substitution
function BackSubst(coeff : array(n,n), const : vector(n), sol : vector(n)) sol[n] := const[n] / coeff[n][n] for i = n - 1 to 1 sum := const[i] for j <- i + 1 to n sum := sum - coeff[i][j] * sol[j] end for sol[i] := sum / coeff[i][i] end for end function
// Naive Gaussian algorithm
function NaiveGaussian(coeff : array(n,n), const : vector(n)) sol := new array(n,n) call FwdElimination(coeff,const) call BackSubst(coeff, const, sol) end function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started