X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=dunshire%2Fmatrices.py;h=94f841d39f888392624077afd12bcdcb7e0c3c19;hb=cb34e104961ce1da242017a0e5ebf60c3fe18a1d;hp=2d4bb17c98a9187e2cacaa0094ef9c0cfe3c4600;hpb=ed86c0467de2f8903d9a18c28fa478412cd9a52e;p=dunshire.git diff --git a/dunshire/matrices.py b/dunshire/matrices.py index 2d4bb17..94f841d 100644 --- a/dunshire/matrices.py +++ b/dunshire/matrices.py @@ -3,6 +3,7 @@ Utility functions for working with CVXOPT matrices (instances of the class:`cvxopt.base.matrix` class). """ +from copy import copy from math import sqrt from cvxopt import matrix from cvxopt.lapack import gees, gesdd, syevr @@ -140,7 +141,10 @@ def eigenvalues(symmat): domain_dim = symmat.size[0] eigs = matrix(0, (domain_dim, 1), tc='d') - syevr(symmat, eigs) + + # Create a copy of ``symmat`` here because ``syevr`` clobbers it. + dummy = copy(symmat) + syevr(dummy, eigs) return list(eigs) @@ -418,10 +422,6 @@ def condition_number(mat): Examples -------- - >>> condition_number(identity(1, typecode='d')) - 1.0 - >>> condition_number(identity(2, typecode='d')) - 1.0 >>> condition_number(identity(3, typecode='d')) 1.0 @@ -435,7 +435,7 @@ def condition_number(mat): """ num_eigs = min(mat.size) - eigs = matrix(0, (num_eigs,1), tc='d') + eigs = matrix(0, (num_eigs, 1), tc='d') gesdd(mat, eigs) if len(eigs) > 0: