diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-07-31 19:34:57 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-07-31 19:34:57 +0000 |
commit | 0bd7d94f96b10781ef8b0c381b295aee41a3458f (patch) | |
tree | 42d522a0e379bd6be562ca3d2bc2b996c643375c /numpy/linalg/linalg.py | |
parent | e4c823dd9d0a3d6fdf6a5f3f7b06b586bd946d11 (diff) | |
download | numpy-0bd7d94f96b10781ef8b0c381b295aee41a3458f.tar.gz |
Fix-up invalid casting back to real when complex result.
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r-- | numpy/linalg/linalg.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 9627b681c..d1de7fea2 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -42,9 +42,17 @@ _real_types_map = {single : single, csingle : single, cdouble : double} +_complex_types_map = {single : csingle, + double : cdouble, + csingle : csingle, + cdouble : cdouble} + def _realType(t, default=double): return _real_types_map.get(t, default) +def _complexType(t, default=cdouble): + return _complex_types_map.get(t, default) + def _linalgRealType(t): """Cast the type t to either double or cdouble.""" return double @@ -207,6 +215,7 @@ def eigvals(a): result_t = _realType(result_t) else: w = wr+1j*wi + result_t = _complexType(result_t) if results['info'] > 0: raise LinAlgError, 'Eigenvalues did not converge' return w.astype(result_t) @@ -308,6 +317,8 @@ eigenvalue u[i]. Satisfies the equation dot(a, v[:,i]) = u[i]*v[:,i] for i in range(len(ind)/2): v[ind[2*i]] = vr[ind[2*i]] + 1j*vr[ind[2*i+1]] v[ind[2*i+1]] = vr[ind[2*i]] - 1j*vr[ind[2*i+1]] + result_t = _complexType(result_t) + if results['info'] > 0: raise LinAlgError, 'Eigenvalues did not converge' vt = v.transpose().astype(result_t) |