Advertisement
smmac72

B

Apr 1st, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import numpy as np
  2.  
  3. n = int(input())
  4. # arr a
  5. A = np.diag(np.arange(1, n + 1))
  6.  
  7. # arr b
  8. re = np.r_[ (n // 2) * [1, 0] + (n % 2) * [1] ]
  9. ro = np.r_[ (n // 2) * [0, 1] + (n % 2) * [0] ]
  10. B = np.row_stack((n // 2) * (re, ro))
  11. if (np.shape(B)[0] != n):
  12.     B = np.vstack((B, re))
  13.  
  14. # arr c
  15.  
  16. C = np.ones((n,n), dtype = 'float')
  17. C[1:-1, 1:-1] = 0
  18. C = C * 10
  19.  
  20. # arr d
  21. D = np.linalg.inv(np.add(np.matmul(np.transpose(B), B), A)) + np.matmul(np.transpose(C), C)
  22. out = np.linalg.det(D)
  23.  
  24. print(out)
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement