numpy-100 icon indicating copy to clipboard operation
numpy-100 copied to clipboard

An alternative solution for Q.82

Open iamyifan opened this issue 2 years ago • 3 comments

  1. 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))

iamyifan avatar Dec 11 '21 13:12 iamyifan

Not sure to see the link between the question and your answer.

rougier avatar Dec 15 '21 12:12 rougier

Not sure to see the link between the question and your answer.

My bad. I've updated Q.82 in my last comment.

iamyifan avatar Dec 15 '21 12:12 iamyifan

Should I close this issue then?

rougier avatar Dec 15 '21 18:12 rougier