Question: Develop a python implementation of Gaussian elimination using partial pivoting. Develop a python code reducing echelon matrices to their reduced echelon forms. You can use
Develop a python implementation of Gaussian elimination using partial pivoting.
Develop a python code reducing echelon matrices to their reduced echelon forms.
You can use the python functions in the attached file. The shorter and smarter the python codes, the higher the grades.
Finding the bugs and the shortcomings of the attached example code will increase your grade.
import numpy as np
from scipy import linalg
def eliminateColA k:
# guarantee that A is float type
if Adtype.kind f and Adtype.kind c: return None
# load dimensions
dimdim npshapeA
# initialize outputs
swap npidentitydimdtypefloat
oper npidentitydimdtypefloat
# k dim
k kdim
# if the column k is zero column, return
if A:kany False: return swap,oper
i
if k :
# find a row i whose left most k entries are all zero
while i dim:
if Ai:kany False: break
i
# find a nonzero element Aik to use as a pivot
i i;
while i dim:
if Aik: break
i
if i dim: return swap,oper
# swap the row i with the row i
if i i: Aii Aii;swapii swapii
# row i is the pivot row and Ajk is zero for i:
if Aij:
quot Aij Akj
Ai: Ai: quotAk:
operikquot
i
return oper
def eliminateScaleA:
# guarantee that A is float type
if Adtype.kind f and Adtype.kind c: return None
# load dimensions
dimdim npshapeA
# initialize outputs
oper npidentitydimdtypefloat
# find pivots
i
while i dim:
j
while j dim:
if Aij: j; continue
else:
operiiAij
Aij: Aij:Aij
break
j
i
return oper
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
