]> gitweb.michael.orlitzky.com - dunshire.git/blobdiff - dunshire/matrices.py
Use the DEBUG_FLOAT_FORMAT when printing exception details.
[dunshire.git] / dunshire / matrices.py
index bcf83778d62752436f7894b5a6fbad4cc3e1012e..6d5bbc8f667dce05feb93ec9fabcf42340f1157e 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
@@ -142,7 +143,7 @@ def eigenvalues(symmat):
     eigs = matrix(0, (domain_dim, 1), tc='d')
 
     # Create a copy of ``symmat`` here because ``syevr`` clobbers it.
     eigs = matrix(0, (domain_dim, 1), tc='d')
 
     # Create a copy of ``symmat`` here because ``syevr`` clobbers it.
-    dummy = matrix(symmat, symmat.size)
+    dummy = copy(symmat)
     syevr(dummy, eigs)
     return list(eigs)
 
     syevr(dummy, eigs)
     return list(eigs)
 
@@ -329,12 +330,12 @@ def norm(matrix_or_vector):
     --------
 
         >>> v = matrix([1,1])
     --------
 
         >>> v = matrix([1,1])
-        >>> print('{:.5f}'.format(norm(v)))
-        1.41421
+        >>> norm(v)
+        1.414...
 
         >>> A = matrix([1,1,1,1], (2,2))
         >>> norm(A)
 
         >>> A = matrix([1,1,1,1], (2,2))
         >>> norm(A)
-        2.0
+        2.0...
 
     """
     return sqrt(inner_product(matrix_or_vector, matrix_or_vector))
 
     """
     return sqrt(inner_product(matrix_or_vector, matrix_or_vector))
@@ -421,10 +422,6 @@ def condition_number(mat):
     Examples
     --------
 
     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
 
     >>> condition_number(identity(3, typecode='d'))
     1.0