alternative solution for Q.82

This commit is contained in:
Jeff1999 2021-07-27 10:11:29 +08:00
parent c3497d3bc3
commit 731d575569

View File

@ -1148,7 +1148,7 @@ print(R)
Compute a matrix rank (★★★) Compute a matrix rank (★★★)
< h82 < h82
hint: np.linalg.svd hint: np.linalg.svd, np.linalg.matrix_rank
< a82 < a82
# Author: Stefan van der Walt # Author: Stefan van der Walt
@ -1158,6 +1158,12 @@ U, S, V = np.linalg.svd(Z) # Singular Value Decomposition
rank = np.sum(S > 1e-10) rank = np.sum(S > 1e-10)
print(rank) print(rank)
# alternative solution:
# Author: Jeff Luo (@Jeff1999)
rank = np.linalg.matrix_rank(Z)
print(rank)
< q83 < q83
How to find the most frequent value in an array? How to find the most frequent value in an array?