]> gitweb.michael.orlitzky.com - dunshire.git/blobdiff - dunshire/matrices.py
Clean up and document some of the new test code.
[dunshire.git] / dunshire / matrices.py
index 2d4bb17c98a9187e2cacaa0094ef9c0cfe3c4600..29c5867aabe544f768a1b1ce3862f14c0a316712 100644 (file)
@@ -3,6 +3,7 @@ Utility functions for working with CVXOPT matrices (instances of the
 class:`cvxopt.base.matrix` class).
 """
 
 class:`cvxopt.base.matrix` class).
 """
 
+from copy import copy
 from math import sqrt
 from cvxopt import matrix
 from cvxopt.lapack import gees, gesdd, syevr
 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')
 
     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)
 
 
     return list(eigs)
 
 
@@ -435,7 +439,7 @@ def condition_number(mat):
 
     """
     num_eigs = min(mat.size)
 
     """
     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:
     gesdd(mat, eigs)
 
     if len(eigs) > 0: