An alternative solution for Q.82
iamyifan opened this issue · 3 comments
iamyifan commented
- Compute a matrix rank (★★★)
hint: np.linalg.svd# Author: Stefan van der Walt
Z = np.random.uniform(0,1,(10,10))
U, S, V = np.linalg.svd(Z) # Singular Value Decomposition
rank = np.sum(S > 1e-10)
print(rank)
numpy.linalg.matrix_rank
Doc provides an alternative way to compute matrix rank.
The alternative solution will be:
from numpy.linalg import matrix_rank
Z = np.random.uniform(0,1,(10,10))
print(matrix_rank(Z))
rougier commented
Not sure to see the link between the question and your answer.
iamyifan commented
Not sure to see the link between the question and your answer.
My bad. I've updated Q.82 in my last comment.
rougier commented
Should I close this issue then?