Reputation: 103
How can I find sqrt
of sparse matrix containing negative numbers in python? scipy.sparse.csr_matrix.sqrt
and numpy.sqrt
doesn't work for negative numbers. I also tried to use cmath.sqrt(mat_name.data)
. But it's not working also.
Upvotes: 1
Views: 284
Reputation: 103
from numpy.lib.scimath import sqrt
works to find sqrt
of sparse matrix with negative numbers. Found the answer here How can I take the square root of -1 using python? from @David Zwicker
Upvotes: 1