summaryrefslogtreecommitdiff
path: root/numpy/linalg/linalg.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r--numpy/linalg/linalg.py11
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)