Skip to content

Commit 18a5097

Browse files
authored
Merge pull request #243 from Gattocrucco/improve-sol-82
Improve solution to exercise 82
2 parents 9be9c8c + 5b6d050 commit 18a5097

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

source/exercises100.ktx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,8 @@ hint: np.linalg.svd, np.linalg.matrix_rank
12251225

12261226
Z = np.random.uniform(0,1,(10,10))
12271227
U, S, V = np.linalg.svd(Z) # Singular Value Decomposition
1228-
rank = np.sum(S > 1e-10)
1228+
threshold = len(S) * S.max() * np.finfo(S.dtype).eps
1229+
rank = np.sum(S > threshold)
12291230
print(rank)
12301231

12311232
# alternative solution:

0 commit comments

Comments
 (0)