Examples
--------
- >>> condition_number(identity(3, typecode='d'))
+ >>> condition_number(identity(3))
1.0
- >>> A = matrix([[2,1],[1,2]], tc='d')
+ >>> A = matrix([[2,1],[1,2]])
>>> abs(condition_number(A) - 3.0) < options.ABS_TOL
True
- >>> A = matrix([[2,1j],[-1j,2]], tc='z')
+ >>> A = matrix([[2,1j],[-1j,2]])
>>> abs(condition_number(A) - 3.0) < options.ABS_TOL
True
"""
num_eigs = min(mat.size)
eigs = matrix(0, (num_eigs, 1), tc='d')
- gesdd(mat, eigs)
+ typecode = 'd'
+ if any([isinstance(entry, complex) for entry in mat]):
+ typecode = 'z'
+ dummy = matrix(mat, mat.size, tc=typecode)
+ gesdd(dummy, eigs)
if len(eigs) > 0:
return eigs[0]/eigs[-1]