Skip to content

Instantly share code, notes, and snippets.

@ntuaha
Created November 16, 2019 17:01
Show Gist options
  • Save ntuaha/d7272baf534379be9d9f48333758ace9 to your computer and use it in GitHub Desktop.
Save ntuaha/d7272baf534379be9d9f48333758ace9 to your computer and use it in GitHub Desktop.
神奇計算
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@catdingding
Copy link

要移除指定的 index
可以使用 np.delete

U = np.zeros((N,N))
for i in range(N):
    lambda_D = np.delete(w, i)
    denominator = np.prod(w[i]-lambda_D)
    for j in range(N):
        M = np.delete(A1, j, 0)
        M = np.delete(M, j, 1)
        w2, v2 = np.linalg.eig(M)
        fraction = np.prod(w[i]-w2)
        U[j,i] = fraction/denominator

@ntuaha
Copy link
Author

ntuaha commented Nov 17, 2019

要移除指定的 index
可以使用 np.delete

U = np.zeros((N,N))
for i in range(N):
    lambda_D = np.delete(w, i)
    denominator = np.prod(w[i]-lambda_D)
    for j in range(N):
        M = np.delete(A1, j, 0)
        M = np.delete(M, j, 1)
        w2, v2 = np.linalg.eig(M)
        fraction = np.prod(w[i]-w2)
        U[j,i] = fraction/denominator

感謝!這個更加簡潔好讀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment