[SciPy-user] math operations on sparse matrices
josef.pktd@gmai...
josef.pktd@gmai...
Sat Feb 21 13:28:51 CST 2009
I have a (dok) sparse distance matrix and I would like to take the
exponential of the distances
The direct method doesn't work
>>> Mexp = np.exp(-M)
Traceback (most recent call last):
File "<pyshell#31>", line 1, in <module>
Mexp = np.exp(-M)
AttributeError: exp
The following seems to work. What is the recommended way for doing
these transformations?
I didn't see anything in the docs.
>>> T1 = ssp.KDTree(xs3[::k,:],leafsize=2)
>>> M = T1.sparse_distance_matrix(T1, r)
>>> Mexp = M.copy()
>>> for k,v in M.items():
Mexp[k]=np.exp(-v)
thanks,
Josef
More information about the SciPy-user
mailing list