Skip to content
Snippets Groups Projects
Commit 48293415 authored by Vlad Niculae's avatar Vlad Niculae Committed by Andreas Mueller
Browse files

Vectorize singular value inversion

parent 0946f594
No related branches found
No related tags found
No related merge requests found
...@@ -351,11 +351,9 @@ def symmetric_pinv(a, cond=None, rcond=None): ...@@ -351,11 +351,9 @@ def symmetric_pinv(a, cond=None, rcond=None):
cond = {0: feps * 1e3, 1: eps * 1e6}[_array_precision[t]] cond = {0: feps * 1e3, 1: eps * 1e6}[_array_precision[t]]
n = a.shape[0] n = a.shape[0]
cutoff = cond * np.maximum.reduce(s) cutoff = cond * np.maximum.reduce(s)
psigma = np.zeros((n, n), t) psigma = np.zeros(n, t)
for i in range(len(s)): above_cutoff = np.where(s > cutoff)
if s[i] > cutoff: psigma[above_cutoff] = 1.0 / np.conjugate(s[above_cutoff])
psigma[i, i] = 1.0 / np.conjugate(s[i])
#XXX: use lapack/blas routines for dot #XXX: use lapack/blas routines for dot
#XXX: above comment is from scipy, but I (@vene)'ll take a look #XXX: above comment is from scipy, but I (@vene)'ll take a look
return np.transpose(np.conjugate(np.dot(np.dot(u, psigma), return np.transpose(np.conjugate(np.dot(u * psigma, u.T.conjugate())))
u.T.conjugate())))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment