小编Jac*_*Liu的帖子

How to implement LU decomposition with partial pivoting in Python?

I want to implement my own LU decomposition P,L,U = my_lu(A), so that given a matrix A, computes the LU decomposition with partial pivoting. But I only know how to do it without pivoting. Can anyone help to do the partial pivoting?

def lu(A):

    import numpy as np

    # Return an error if matrix is not square
    if not A.shape[0]==A.shape[1]:
        raise ValueError("Input matrix must be square")

    n = A.shape[0] 

    L = np.zeros((n,n),dtype='float64') 
    U = np.zeros((n,n),dtype='float64') 
    U[:] = A 
    np.fill_diagonal(L,1) # …
Run Code Online (Sandbox Code Playgroud)

python matrix decomposition

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

decomposition ×1

matrix ×1

python ×1