python - condition number of sparse matrix -


i'm trying obtain condition number of scipy sparse matrix. way managed far converting matrix dense, , obtaining eigenvalues of it:

$ python python 3.5.2 (v3.5.2:4def2a2901a5, jun 26 2016, 10:47:25)  [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "help", "copyright", "credits" or "license" more information. >>> numpy import array >>> import numpy np >>> import scipy.sparse sparse >>> = array([0,3,1,0]) >>> j = array([0,3,1,2]) >>> v = array([4,5,7,9]) >>> = sparse.coo_matrix((v,(i,j)),shape=(4,4)) >>> = a.todense() >>> eig = np.linalg.eig(a) >>> eig = eig[0].real, np.array(eig[1].real) >>> def split(array, cond): ...     return (array[cond], array[~cond]) ...  >>> eigv, 0 = split(eig[0], eig[0]>1e-10) >>> cond = max(eigv) / min(eigv) >>> cond 1.75 

as may expect, becomes unfeasible large matrices. wondering how done in python?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -