Advertisement
Guest User

Untitled

a guest
Dec 16th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. In [308]: A = np.array([[1,-2j],[2j,5]])
  2.  
  3. In [310]: B = np.array([[1, 2], [2, 4]])
  4.  
  5. In [311]: def test_matrices(*args):
  6.      ...:     result = {'success': [], 'failure': []}
  7.      ...:     for m in args:
  8.      ...:         try:
  9.      ...:             np.linalg.cholesky(m)
  10.      ...:             result['success'].append(m)
  11.      ...:         except np.linalg.LinAlgError:
  12.      ...:             result['failure'].append(m)
  13.      ...:     return result
  14.      ...:
  15.  
  16. In [312]: test_matrices(A, B)
  17. Out[312]:
  18. {'success': [array([[ 1.+0.j, -0.-2.j],
  19.          [ 0.+2.j,  5.+0.j]])],
  20.  'failure': [array([[1, 2],
  21.          [2, 4]])]}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement