]> gitweb.michael.orlitzky.com - dunshire.git/blobdiff - src/dunshire/matrices.py
Use syevr instead of syev for eigenvalues.
[dunshire.git] / src / dunshire / matrices.py
index 38d4afe78efaad7665b71d936c8ba9e8309de581..bf8ae03ee416e443245ed45b76fc1ce614d8990a 100644 (file)
@@ -5,19 +5,28 @@ class:`cvxopt.base.matrix` class).
 
 from math import sqrt
 from cvxopt import matrix
-from cvxopt.lapack import syev
+from cvxopt.lapack import syevr
 
 import options
 
+
 def append_col(left, right):
     """
-    Append the matrix ``right`` to the right side of the matrix ``left``.
+    Append two matrices side-by-side.
 
     Parameters
     ----------
+
     left, right : matrix
         The two matrices to append to one another.
 
+    Returns
+    -------
+
+    matrix
+        A new matrix consisting of ``right`` appended to the right
+        of ``left``.
+
     Examples
     --------
 
@@ -39,15 +48,23 @@ def append_col(left, right):
     """
     return matrix([left.trans(), right.trans()]).trans()
 
+
 def append_row(top, bottom):
     """
-    Append the matrix ``bottom`` to the bottom of the matrix ``top``.
+    Append two matrices top-to-bottom.
 
     Parameters
     ----------
+
     top, bottom : matrix
         The two matrices to append to one another.
 
+    Returns
+    -------
+
+    matrix
+        A new matrix consisting of ``bottom`` appended below ``top``.
+
     Examples
     --------
 
@@ -84,9 +101,15 @@ def eigenvalues(symmat):
     symmat : matrix
         The real symmetric matrix whose eigenvalues you want.
 
+    Returns
+    -------
+
+    list of float
+       A list of the eigenvalues (in no particular order) of ``symmat``.
 
     Raises
     ------
+
     TypeError
         If the input matrix is not symmetric.
 
@@ -113,7 +136,7 @@ def eigenvalues(symmat):
 
     domain_dim = symmat.size[0]
     eigs = matrix(0, (domain_dim, 1), tc='d')
-    syev(symmat, eigs)
+    syevr(symmat, eigs)
     return list(eigs)
 
 
@@ -129,9 +152,16 @@ def identity(domain_dim):
 
     Returns
     -------
+
     matrix
         A ``domain_dim``-by-``domain_dim`` dense integer identity matrix.
 
+    Raises
+    ------
+
+    ValueError
+        If you ask for the identity on zero or fewer dimensions.
+
     Examples
     --------
 
@@ -163,9 +193,16 @@ def inner_product(vec1, vec2):
 
     Returns
     -------
+
     float
         The inner product of ``vec1`` and ``vec2``.
 
+    Raises
+    ------
+
+    TypeError
+        If the lengths of ``vec1`` and ``vec2`` differ.
+
     Examples
     --------