Question: Write a matlab function to execute gaussian elimination with scaled partial pivoting based off of the following psuedo code: input variables: n (some number), a

Write a matlab function to execute gaussian elimination with scaled partial pivoting based off of the following psuedo code:

input variables: n (some number), aij (nxn coefficient array), li (the index array)

other terms and variables used si (scale array), Write a matlab function to execute gaussian elimination with scaled partial pivoting denotes replacement of value with what is on the left, I believe in matlab an equal sign is what we're looking for.

Psuedo code:

function Gauss(n, (aij), (li))

integer i, j, k, n

real r, rmax, smax, xmult

real array (aij)1:n x 1:n, (li)1:n; real array allocate (si)1:n

%in the first loop the index array is being established li=i then scale array is computed

for i = 1 to n

libased off of the following psuedo code: input variables: n (some number),i

smaxaij (nxn coefficient array), li (the index array) other terms and variables 0

for j =1 to n

smax used si (scale array), denotes replacement of value with what is on max(smax, abs.value(aij)

end for

si the left, I believe in matlab an equal sign is what we're smax

end for

for k = 1 to n-1 % initiating principle outer loop

%k is the subscript of the variable whose coefficients will be made 0 in the array (aij) in other words, k is the index of the %column in which ne 0's are being created

rmax looking for. Psuedo code: function Gauss(n, (aij), (li)) integer i, j, k, 0

for i = k to n

% r is the ratio between the the array and scale array and used to determined the correct pivot row

r n real r, rmax, smax, xmult real array (aij)1:n x 1:n, (li)1:n; abs. value (aij/sl_i) %l_i = li

%calculating the gratest ratio rmax and the index j where it occurs

if (r > rmax) then

rmax real array allocate (si)1:n %in the first loop the index array is r

j being established li=i then scale array is computed for i = 1 i

end if

end for

% lj and lk are swapped in array li

ljto n lii smax 0 for j =1 to n smax max(smax,lk

%next loop makes the arithmetic modifications to aij due to subtracting multiples of row lk from rows lk+1, lk+2,..., ln. First the multiplier is computed and stored; then the subtraction occurs in a loop.

for i = k +1 to n

xmult abs.value(aij) end for si smax end for for k = 1 to al_i,k/al_k,k

al_i,kn-1 % initiating principle outer loop %k is the subscript of the xmult

for j = k+1 to n

al_i,j variable whose coefficients will be made 0 in the array (aij) inal_i,j -(xmult)*al_k,j

end for

end for

end for

deallocate array (si)

end function Gauss

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!