Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An alternative solution for Q.82 #163

Open
iamyifan opened this issue Dec 11, 2021 · 3 comments
Open

An alternative solution for Q.82 #163

iamyifan opened this issue Dec 11, 2021 · 3 comments

Comments

@iamyifan
Copy link
Contributor

iamyifan commented Dec 11, 2021

  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))
@rougier
Copy link
Owner

rougier commented Dec 15, 2021

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

@iamyifan
Copy link
Contributor Author

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

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

@rougier
Copy link
Owner

rougier commented Dec 15, 2021

Should I close this issue then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants