import numpy as np
# The following two functions calculate the LU decomposition of the given matrix
# A using either parital or full pivoting. The resulting lower and upper
# triangular matricies override the passed matrix. When using partial pivoting
# the return value is a permutation array of the indicies of the rows of A and
# when using full pivoting the corresponding function shall return a tuple of
# permuation arrays of the indicies of the rows and columns of A respectively.
# Thus the following equalities shall hold, at least approximately (that is up
# to numerical error):
# A = np.array([[...], [...], ..., [...]])
#
# partial = A.copy()
# p = partialPivotLU(partial)
# L, U = np.tril(partial, -1), np.triu(partial)
# L = L + np.diag(np.ones(L.shape[0]))
#
# L @ U == A[p, :] # up to numerical error
#
# full = A.copy()
# p, q = fullPivotLU(full)
# L, U = np.tril(full, -1), np.triu(full)
# L = L + np.diag(np.ones(L.shape[0]))
#
# L @ U == A[p, q] # up to numerical error
#
# You can base your solution on the provided code from the scripture from the
# lecture, but note that there a full permutation matrix is contstructed and the
# LU decomposition is also not done in-place.
def partialPivotLU(A):
return np.array([])
def fullPivotLU(A):
return (np.array([]), np.array([]))
if __name__ == "__main__":
print("Hello, World!")