Merge pull request #243 from Gattocrucco/improve-sol-82

Improve solution to exercise 82
This commit is contained in:
Nicolas P. Rougier 2025-08-26 11:06:02 +02:00 committed by GitHub
commit 18a5097890
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1225,7 +1225,8 @@ hint: np.linalg.svd, np.linalg.matrix_rank
Z = np.random.uniform(0,1,(10,10))
U, S, V = np.linalg.svd(Z) # Singular Value Decomposition
rank = np.sum(S > 1e-10)
threshold = len(S) * S.max() * np.finfo(S.dtype).eps
rank = np.sum(S > threshold)
print(rank)
# alternative solution: