python - Is there a way to tell what makes a particular numpy array singular? -


i trying generate few large arrays, , @ least 1 ending being singular, made obvious familiar error message:

  file "c:\anaconda3\lib\site-packages\numpy\linalg\linalg.py", line 90, in _raise_linalgerror_singular     raise linalgerror("singular matrix")  linalgerror: singular matrix 

of course not want array singular, more interested in determining why array singular. mean have way answer following questions without manually checking each entry:

  1. is array square? (i believe returned separate error message, convenient, i'll include singularity property anyway)

  2. are rows populated zeros?

  3. are columns populated zeros?

  4. are rows not linearly independent of other rows?

for relatively small arrays, first 2 conditions answered visual inspection. however, because arrays substantially large, not want have go in , manually check each array element see if of conditions met.

i tried pulling linalg.py script see if see how determines matrix singular, not tell how determines matrix singular.

(this paragraph edited clarity) tried searching info online, , nothing seemed of help. topics seemed answer form of following questions/objectives: 1) "i want python tell me if matrix singular" or 2) why python giving me error message". because know matrix/matrices singular, neither of these 2 questions of importance me.

again, not looking answer along lines of, "oh, particular matrix singular because . . .". looking method can use on singular matrix determine (especially large arrays) causing singularity.

is there built-in python function this, or there other relatively simple way before try create function me?

singular matrices have @ least 1 eigenvalue equal zero. can create diagonalizable singular matrix starting eigenvalue decomposition:

a = v d v^{-1} 

d diagonal matrix of eigenvalues. create matrix v, diagonal matrix d has @ least 1 0 in diagonal, , singular.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -