Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def get_mat(L:int)->np.ndarray:
- N = L * 2 + 1
- mat = np.zeros(N) - np.identity(N)
- idx = np.arange(N-1)
- idy = idx + 1
- mat[idx[:L], idy[:L]] = 1/3
- mat[idx[L:], idy[L:]] = 2/3
- mat[idy[:L-1], idx[:L-1]] = 2/3
- mat[idy[L-1:], idx[L-1:]] = 1/3
- return mat
- for i in range(11):
- mat = get_mat(i)
- det = np.linalg.det(mat)
- mat_inv = None
- if det != 0:
- mat_inv = np.linalg.inv(mat)
- print(mat, mat_inv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement