[cvxopt] 13/64: Imported Upstream version 0.9.2

Andreas Tille tille at debian.org
Wed Jul 20 11:23:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository cvxopt.

commit cef51c29218fab35b7ec122257b51099e6766ea1
Author: Andreas Tille <tille at debian.org>
Date:   Wed Jul 20 08:26:52 2016 +0200

    Imported Upstream version 0.9.2
---
 INSTALL                       |  30 ++---
 LICENSE                       |   2 +-
 doc/base.tex                  | 284 +++++++++++++++++++-----------------------
 doc/base_sparse.tex           | 236 +++++++++++++----------------------
 doc/blas.tex                  |  14 +--
 doc/coneprog.tex              |  88 ++++++-------
 doc/cvxopt.tex                |   8 +-
 doc/intro.tex                 |  11 +-
 doc/lapack.tex                |  48 ++++---
 doc/modeling.tex              |  81 ++++++------
 doc/printing.tex              | 115 +++++++++++++++++
 doc/solvers.tex               |   6 +-
 doc/spsolvers.tex             |  57 ++++-----
 examples/book/chap6/penalties |   6 +-
 examples/book/chap6/robls     |   6 +-
 examples/book/chap6/smoothrec |   4 +-
 examples/book/chap6/tv        |   6 +-
 examples/book/chap7/chernoff  |   4 +-
 examples/doc/chap10/l1svc     |   2 +-
 examples/doc/chap10/normappr  |   2 +-
 examples/doc/chap10/roblp     |   2 +-
 examples/doc/chap4/acent      |   6 +-
 examples/doc/chap8/l1         |   6 +-
 examples/doc/chap8/mcsdp      |   4 +-
 examples/doc/chap8/qcl1       |   6 +-
 examples/doc/chap9/acent      |  10 +-
 examples/doc/chap9/l1regls    |   8 +-
 examples/doc/chap9/robls      |   8 +-
 src/C/amd.c                   |   2 +-
 src/C/base.c                  |  21 +---
 src/C/blas.c                  |   2 +-
 src/C/cholmod.c               |   2 +-
 src/C/cvxopt.h                |   2 +-
 src/C/dense.c                 | 106 ++++------------
 src/C/dsdp.c                  |   2 +-
 src/C/fftw.c                  |   2 +-
 src/C/glpk.c                  |   2 +-
 src/C/{random.c => gsl.c}     |  10 +-
 src/C/lapack.c                |   2 +-
 src/C/misc.h                  |   2 +-
 src/C/sparse.c                |  88 ++++---------
 src/C/umfpack.c               |   2 +-
 src/python/__init__.py        | 103 ++++++++++++++-
 src/python/coneprog.py        |   2 +-
 src/python/cvxprog.py         |   2 +-
 src/python/info.py            |   4 +-
 src/python/misc.py            |   2 +-
 src/python/modeling.py        |   2 +-
 src/python/mosek.py           |   2 +-
 src/python/printing.py        | 196 +++++++++++++++++++++++++++++
 src/python/solvers.py         |   2 +-
 src/setup.py                  |  35 +++---
 52 files changed, 924 insertions(+), 731 deletions(-)

diff --git a/INSTALL b/INSTALL
index ed21677..5bbd30c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,13 +1,13 @@
-Installation instructions for CVXOPT Version 0.9.1.
+Installation instructions for CVXOPT Version 0.9.2.
 
-The package requires version 2.3 or newer of Python, and is built 
-from source, so the header files and libraries for Python must be 
-installed, as well as the core binaries.
+The package requires version 2.3 or newer of Python, and is built from 
+source, so the header files and libraries for Python must be installed, 
+as well as the core binaries.
 
 The installation requires either ATLAS or BLAS + LAPACK.  Using 
-architecture optimized ATLAS libraries is recommended and gives a 
-large performance improvement over standard BLAS & LAPACK libraries.  
-Both header files and libraries must be installed.  
+architecture optimized ATLAS libraries is recommended and gives a large 
+performance improvement over standard BLAS & LAPACK libraries.  Both 
+header files and libraries must be installed.  
 
 The following software libraries are optional.  
 
@@ -29,25 +29,27 @@ Configuration script:
 ---------------------
 Edit src/setup.py and update the following variables:
 
-- ATLAS_LIB_DIR: the directory containing the lapack and blas libraries.
+- ATLAS_LIB_DIR: the directory containing the LAPACK and BLAS libraries.
 
-- BUILD_GSL: set this variableto 1 to install the cvxopt.random module,
-  which is based on the random number generators of the GSL library. 
-- GSL_LIB_DIR: the directory containing the libgsl.
+- BUILD_GSL: set this variable to 1 if you would like to use the GSL  
+  random number generators for constructing random matrices in CVXOPT.  
+  If BULD_GSL is 0, the Python random number generators will be used 
+  instead.  
+- GSL_LIB_DIR: the directory containing libgsl.
 - GSL_iNC_DIR: the directory containing the GSL header files. 
 
 - BUILD_FFTW: set this variable to 1 to install the cvxopt.fftw module,
   which is an interface to FFTW.
-- FFTW_LIB_DIR: the directory containing the libfftw3.
+- FFTW_LIB_DIR: the directory containing libfftw3.
 - FFTW_INC_DIR: the directory containing fftw.h.
 
 - BUILD_GLPK: set this variable to 1 to enable support for the linear
-  programming solver in GLPK.  
+  programming solver GLPK.  
 - GLPK_LIB_DIR: the directory containing libglpk.
 - GLPK_INC_DIR: the directory containing glpk.h. 
 
 - BUILD_DSDP: set this variable to 1 to enable support for the semidefinite
-  programming solver in DSDP.
+  programming solver DSDP.
 - DSDP_LIB_DIR: the directory containing libdsdp.
 - DSDP_INC_DIR: the directory containing dsdp5.h.
 
diff --git a/LICENSE b/LICENSE
index e7fda90..0b667ff 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-CVXOPT version 0.9.1.  Copyright (c) 2004-2007 J. Dahl and L. Vandenberghe.
+CVXOPT version 0.9.2.  Copyright (c) 2004-2007 J. Dahl and L. Vandenberghe.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/doc/base.tex b/doc/base.tex
index eff0a8b..47ea1f6 100644
--- a/doc/base.tex
+++ b/doc/base.tex
@@ -35,13 +35,13 @@ double to complex when used to create a matrix of type \ztc).
 >>> from cvxopt.base import matrix
 >>> A = matrix(1, (1,4))   
 >>> print A
-   1      1      1      1
+[ 1  1  1  1]
 >>> A = matrix(1.0, (1,4))   
 >>> print A
-   1.0000e+00   1.0000e+00   1.0000e+00   1.0000e+00
+[ 1.00e+00  1.00e+00  1.00e+00  1.00e+00]
 >>> A = matrix(1+1j)     
 >>> print A
-   1.0000e+00+j1.0000e+00
+[ 1.00e+00+j1.00e+00]
 \end{verbatim}
 
 \item If \var{x} is a sequence of numbers (list, tuple, \module{array}
@@ -64,8 +64,8 @@ matrix.
 >>> from array import array
 >>> A = matrix(array('i', [0,1,2,3]), (2,2))
 >>> print A
-   0      2
-   1      3
+[ 0  2]
+[ 1  3]
 \end{verbatim}
 
 \item If \var{x} is a dense or sparse matrix (a \mtrx\ or a \spmtrx\ 
@@ -83,27 +83,26 @@ Type conversion takes place when the type of \var{x} differs from
 \begin{verbatim}
 >>> A = matrix([1., 2., 3., 4., 5., 6.], (2,3))  
 >>> print A
-   1.0000e+00   3.0000e+00   5.0000e+00   
-   2.0000e+00   4.0000e+00   6.0000e+00   
+[ 1.00e+00  3.00e+00  5.00e+00]
+[ 2.00e+00  4.00e+00  6.00e+00]
 >>> B = matrix(A, (3,2))  
 >>> print B
-   1.0000e+00   4.0000e+00   
-   2.0000e+00   5.0000e+00   
-   3.0000e+00   6.0000e+00   
+[ 1.00e+00  4.00e+00]
+[ 2.00e+00  5.00e+00]
+[ 3.00e+00  6.00e+00]
 >>> C = matrix(B, tc='z')      
 >>> print C
-   1.0000e+00-j0.0000e+00   4.0000e+00-j0.0000e+00
-   2.0000e+00-j0.0000e+00   5.0000e+00-j0.0000e+00
-   3.0000e+00-j0.0000e+00   6.0000e+00-j0.0000e+00
+[ 1.00e+00-j0.00e+00  4.00e+00-j0.00e+00]
+[ 2.00e+00-j0.00e+00  5.00e+00-j0.00e+00]
+[ 3.00e+00-j0.00e+00  6.00e+00-j0.00e+00]
 >>> from numpy import array
 >>> x = array([[1., 2., 3.], [4., 5., 6.]])
->>> print x
-[[ 1.  2.  3.]
- [ 4.  5.  6.]]
->>> y = matrix(x)
->>> print y
-   1.0000e+00   2.0000e+00   3.0000e+00
-   4.0000e+00   5.0000e+00   6.0000e+00
+>>> x
+array([[ 1.  2.  3.]
+       [ 4.  5.  6.]])
+>>> print matrix(x)
+[ 1.00e+00  2.00e+00  3.00e+00]
+[ 4.00e+00  5.00e+00  6.00e+00]
 \end{verbatim}
 
 \item If \var{x} is a list of lists of matrices 
@@ -121,32 +120,33 @@ a list of empty lists, a value \itc\ is used).
 The same rules for type conversion apply as for scalar \var{x}.
 
 \begin{verbatim}
->>> A = matrix([[1., 2.], [3., 4.], [5., 6.]])
->>> print A
-   1.0000e+00   3.0000e+00   5.0000e+00
-   2.0000e+00   4.0000e+00   6.0000e+00
+>>> print matrix([[1., 2.], [3., 4.], [5., 6.]])
+[ 1.00e+00  3.00e+00  5.00e+00]
+[ 2.00e+00  4.00e+00  6.00e+00]
 >>> A1 = matrix([1, 2], (2,1))
 >>> B1 = matrix([6, 7, 8, 9, 10, 11], (2,3))
 >>> B2 = matrix([12, 13, 14, 15, 16, 17], (2,3))
 >>> B3 = matrix([18, 19, 20], (1,3))
->>> print matrix([[A1, 3.0, 4.0, 5.0], [B1, B2, B3]])
-   1.0000e+00   6.0000e+00   8.0000e+00   1.0000e+01
-   2.0000e+00   7.0000e+00   9.0000e+00   1.1000e+01
-   3.0000e+00   1.2000e+01   1.4000e+01   1.6000e+01
-   4.0000e+00   1.3000e+01   1.5000e+01   1.7000e+01
-   5.0000e+00   1.8000e+01   1.9000e+01   2.0000e+01
+>>> C = matrix([[A1, 3.0, 4.0, 5.0], [B1, B2, B3]])
+>>> print C
+[ 1.00e+00  6.00e+00  8.00e+00  1.00e+01]
+[ 2.00e+00  7.00e+00  9.00e+00  1.10e+01]
+[ 3.00e+00  1.20e+01  1.40e+01  1.60e+01]
+[ 4.00e+00  1.30e+01  1.50e+01  1.70e+01]
+[ 5.00e+00  1.80e+01  1.90e+01  2.00e+01]
 \end{verbatim}
 
 A matrix with a single block-column can be represented by a single 
 list (\ie, when the length of \var{x} is one, it can be replaced with
 \code{\var{x}[0]}).
 \begin{verbatim}
->>> print matrix([B1, B2, B3])
-   6      8      10  
-   7      9      11  
-   12     14     16  
-   13     15     17  
-   18     19     20  
+>>> D = matrix([B1, B2, B3])
+>>> print D
+[  6   8  10]
+[  7   9  11]
+[ 12  14  16]
+[ 13  15  17]
+[ 18  19  20]
 \end{verbatim}
 \EIT
 \end{funcdesc}
@@ -204,9 +204,9 @@ The last two methods are illustrated in the following example.
 >>> from cvxopt.base import matrix
 >>> A = matrix([[1.,2.,3.], [4.,5.,6.]])  
 >>> print A
-  1.0000e+00  4.0000e+00
-  2.0000e+00  5.0000e+00
-  3.0000e+00  6.0000e+00
+[ 1.00e+00  4.00e+00]
+[ 2.00e+00  5.00e+00]
+[ 3.00e+00  6.00e+00]
 >>> f = open('mat.bin','w')
 >>> A.tofile(f)
 >>> f.close()
@@ -215,8 +215,8 @@ The last two methods are illustrated in the following example.
 >>> B.fromfile(f)
 >>> f.close()
 >>> print B
-  1.0000e+00  3.0000e+00  5.0000e+00
-  2.0000e+00  4.0000e+00  6.0000e+00
+[ 1.00e+00  3.00e+00  5.00e+00]
+[ 2.00e+00  4.00e+00  6.00e+00]
 \end{verbatim}
 
 Matrices can also be written to or read from files using the 
@@ -315,13 +315,13 @@ reference (or pointer) to the object referenced by \var{B}.
 \begin{verbatim}
 >>> B = matrix([[1.,2.], [3.,4.]])  
 >>> print B
- 1.0000e+00   3.0000e+00
- 2.0000e+00   4.0000e+00
+[ 1.00e+00  3.00e+00]
+[ 2.00e+00  4.00e+00]
 >>> A = B
 >>> A[0,0] = -1 
 >>> print B   # modifying A[0,0] also modified B[0,0]
--1.0000e+00   3.0000e+00
- 2.0000e+00   4.0000e+00
+[-1.00e+00  3.00e+00]
+[ 2.00e+00  4.00e+00]
 \end{verbatim}
 
 \item The regular (\ie, not in-place) arithmetic operations always 
@@ -332,24 +332,23 @@ return new objects.   Hence \samp{A = +B} is equivalent to
 >>> A = +B
 >>> A[0,0] = -1 
 >>> print B   # modifying A[0,0] does not modify B[0,0]
- 1.0000e+00   3.0000e+00
- 2.0000e+00   4.0000e+00
+[ 1.00e+00  3.00e+00]
+[ 2.00e+00  4.00e+00]
 \end{verbatim}
 
-\item  The in-place operations directly modify the 
- coefficients of the existing matrix object and do not create a new
- object. 
+\item  The in-place operations directly modify the coefficients of the 
+ existing matrix object and do not create a new object. 
 \begin{verbatim}
 >>> B = matrix([[1.,2.], [3.,4.]])  
 >>> A = B
 >>> A *= 2
 >>> print B   # in-place operation also changed B
- 2.0000e+00   6.0000e+00
- 4.0000e+00   8.0000e+00
+[ 2.00e+00  6.00e+00]
+[ 4.00e+00  8.00e+00]
 >>> A = 2*A
 >>> print B   # regular operation creates a new A, so does not change B
- 2.0000e+00   6.0000e+00
- 4.0000e+00   8.0000e+00
+[ 2.00e+00  6.00e+00]
+[ 4.00e+00  8.00e+00]
 \end{verbatim}
 \end{itemize}
 
@@ -409,34 +408,34 @@ The following example illustrates one-argument indexing.
 >>> from cvxopt.base import matrix 
 >>> A = matrix(range(16), (4,4), 'd')
 >>> print A
-   0.0000e+00   4.0000e+00   8.0000e+00   1.2000e+01
-   1.0000e+00   5.0000e+00   9.0000e+00   1.3000e+01
-   2.0000e+00   6.0000e+00   1.0000e+01   1.4000e+01
-   3.0000e+00   7.0000e+00   1.1000e+01   1.5000e+01
+[ 0.00e+00  4.00e+00  8.00e+00  1.20e+01]
+[ 1.00e+00  5.00e+00  9.00e+00  1.30e+01]
+[ 2.00e+00  6.00e+00  1.00e+01  1.40e+01]
+[ 3.00e+00  7.00e+00  1.10e+01  1.50e+01]
 >>> A[4]
 4.0
 >>> I = matrix([0, 5, 10, 15])
 >>> print A[I]      # the diagonal
-   0.0000e+00
-   5.0000e+00
-   1.0000e+01
-   1.5000e+01
+[ 0.00e+00]
+[ 5.00e+00]
+[ 1.00e+01]
+[ 1.50e+01]
 >>> I = [0,2];  J = [1,3]
 >>> print A[2*I+J]  # duplicate I and append J
-   0.0000e+00
-   2.0000e+00
-   0.0000e+00
-   2.0000e+00
-   1.0000e+00
-   3.0000e+00
+[ 0.00e+00]
+[ 2.00e+00]
+[ 0.00e+00]
+[ 2.00e+00]
+[ 1.00e+00]
+[ 3.00e+00]
 >>> I = matrix([0, 2]);  J =  matrix([1, 3])
 >>> print A[2*I+J]  # multiply I by 2 and add J
-   1.0000e+00
-   7.0000e+00
+[ 1.00e+00]
+[ 7.00e+00]
 >>> print A[4::4]   # get every fourth element skipping the first four  
-   4.0000e+00
-   8.0000e+00
-   1.2000e+01
+[ 4.00e+00]
+[ 8.00e+00]
+[ 1.20e+01]
 \end{verbatim}
 
 In two-argument indexing the arguments can be any combinations of the
@@ -446,17 +445,17 @@ indices are scalars, then a scalar is returned.  In all other cases,
 a matrix is returned.  We continue the example.
 \begin{verbatim}
 >>> print A[:,1]
-   4.0000e+00
-   5.0000e+00
-   6.0000e+00
-   7.0000e+00
+[ 4.00e+00]
+[ 5.00e+00]
+[ 6.00e+00]
+[ 7.00e+00]
 >>> J = matrix([0, 2])
 >>> print A[J,J]
-   0.0000e+00   8.0000e+00
-   2.0000e+00   1.0000e+01
+[ 0.00e+00  8.00e+00]
+[ 2.00e+00  1.00e+01]
 >>> print A[:2, -2:]   
-   8.0000e+00   1.2000e+01
-   9.0000e+00   1.3000e+01
+[ 8.00e+00  1.20e+01]
+[ 9.00e+00  1.30e+01]
 \end{verbatim}
 
 Expressions of the form \code{\var{A}[\var{I}]} or 
@@ -485,28 +484,28 @@ The following example illlustrates indexed assignment.
 >>> A = matrix(range(16), (4,4))
 >>> A[::2,::2] = matrix([[-1, -2], [-3, -4]])
 >>> print A
-  -1      4     -3      12
-   1      5      9      13
-  -2      6     -4      14
-   3      7      11     15
+[ -1   4  -3  12]
+[  1   5   9  13]
+[ -2   6  -4  14]
+[  3   7  11  15]
 >>> A[::5] += 1
 >>> print A
-   0      4     -3      12
-   1      6      9      13
-  -2      6     -3      14
-   3      7      11     16
+[  0   4  -3  12]
+[  1   6   9  13]
+[ -2   6  -3  14]
+[  3   7  11  16]
 >>> A[0,:] = -1, 1, -1, 1
 >>> print A
-  -1      1     -1      1 
-   1      6      9      13
-  -2      6     -3      14
-   3      7      11     16
+[ -1   1  -1   1]
+[  1   6   9  13]
+[ -2   6  -3  14]
+[  3   7  11  16]
 >>> A[2:,2:] = xrange(4)
 >>> print A
-  -1      1     -1      1 
-   1      6      9      13
-  -2      6      0      2
-   3      7      1      3
+[ -1   1  -1   1]
+[  1   6   9  13]
+[ -2   6   0   2]
+[  3   7   1   3]
 \end{verbatim}
 
 \section{Built-in Functions} \label{s-builtinfuncs}
@@ -568,19 +567,19 @@ with two arguments.
 >>> A = matrix([[5, -4, 10, -7], [-1, -5, -6, 2], [6, 1, 5, 2],  [-1, 2, -3, -7]])
 >>> B = matrix([[4,-15, 9, -14], [-4, -12, 1, -22], [-10, -9, 9, 12], [-9, -7,-11, -6]])
 >>> print matrix(map(max, A, B), (4,4))   # takes componentwise maximum
-   5     -1      6     -1
-  -4     -5      1      2
-   10     1      9     -3
-  -7      2      12    -6
+[  5  -1   6  -1]
+[ -4  -5   1   2]
+[ 10   1   9  -3]
+[ -7   2  12  -6]
 \end{verbatim}
 
 \code{filter(\var{f},\var{A})}, where \var{f} is a function and 
 \var{A} is a matrix, returns a list containing the elements of \var{A} 
 for which \var{f} is true.
 \begin{verbatim}
->>> print filter(lambda x: x%2, A)         # list of odd elements in A
+>>> filter(lambda x: x%2, A)         # list of odd elements in A
 [5, -7, -1, -5, 1, 5, -1, -3, -7]
->>> print filter(lambda x: -2 < x < 3, A)  # list of elements between -2 and 3
+>>> filter(lambda x: -2 < x < 3, A)  # list of elements between -2 and 3
 [-1, 2, 1, 2, -1, 2]
 \end{verbatim}
 
@@ -649,17 +648,18 @@ The two matrices must have the same size and type.
 \end{funcdesc}
 
 
-\section{Randomly Generated Matrices (\module{cvxopt.random})} 
+\section{Randomly Generated Matrices} 
 \label{s-random}
-The module \module{cvxopt.random} provides functions for generating
-random matrices, using the pseudo-random number generators in the 
-\ulink{GNU Scientific Library (GSL)}{http://www.gnu.org/software/gsl}.
-This module is optional, and only installed when the GSL library is 
-available during the CVXOPT installation.
-
-Two types of random matrices are defined: matrices with normally 
-distributed entries and matrices with uniformly 
-distributed entries.   
+The \module{cvxopt.base} module provides two functions \function{normal()} 
+and \function{uniform()} for generating
+randomly distributed matrices.  The default installation relies on
+the pseudo-random number generators in the Python standard 
+library \module{random}.  Alternatively, the random number generators in 
+the \ulink{GNU Scientific Library (GSL)}{http://www.gnu.org/software/gsl}
+can be used, if this option is selected during the installation of CVXOPT.
+The random matrix functions based on GSL are faster than the default 
+functions based on the \module{random} module.
+
 \begin{funcdesc}{normal}{nrows\optional{, ncols\optional{, 
  mean\optional{, std}}}}
 Returns a type \dtc\ matrix of size \var{nrows} by 
@@ -678,14 +678,21 @@ The default values for the optional arguments are
 \var{ncols}=1, \var{a}=0.0, \var{b}=1.0.
 \end{funcdesc}
 
-\begin{funcdesc}{getseed}{}
-Returns the current seed value (the state of the random number generator).
-\end{funcdesc}
-
 \begin{funcdesc}{setseed}{\optional{value}}
-Sets the seed value.  \var{value} must be an integer.
-If \var{value} is absent or equal to zero, the seed value is taken 
+Sets the state of the random number generator.  \var{value} must be an 
+integer.  If \var{value} is absent or equal to zero, the value is taken 
 from the system clock.  
+If the Python random number generators are used, this is equivalent
+to \function{random.seed(value)}.
+\end{funcdesc}
+
+\begin{funcdesc}{getseed}{}
+Returns the current state of the random number generator.  
+This function is only available if the GSL random number generators are 
+installed.   
+(The state of the random number generators in the Python \module{random} 
+module can be managed via the functions \function{random.getstate()} and 
+\function{random.setstate()}.)
 \end{funcdesc}
 
 
@@ -712,17 +719,17 @@ Conversely, CVXOPT matrices can be used as array-like objects
 in \program{NumPy}.  The following example illustrates the 
 compatibility of CVXOPT matrices and \program{NumPy} arrays. 
 \begin{verbatim}
->>> from cvxopt import matrix
+>>> from cvxopt.base import matrix
 >>> a = matrix(range(6), (2,3), 'd')
 >>> print a
-   0.0000e+00   2.0000e+00   4.0000e+00
-   1.0000e+00   3.0000e+00   5.0000e+00
+[ 0.00e+00  2.00e+00  4.00e+00]
+[ 1.00e+00  3.00e+00  5.00e+00]
 >>> from numpy import array
 >>> b = array(a)
 >>> b
 array([[ 0.  2.  4.]
        [ 1.  3.  5.]])
->>> print a*b
+>>> a*b
 array([[  0.   4.  16.]
        [  1.   9.  25.]])
 >>> from numpy import mat
@@ -739,34 +746,3 @@ In the first product, \code{a*b} is interpreted as \program{NumPy} array
 multiplication, \ie, componentwise multiplication.
 The second product \code{a.T*c} is interpreted as \program{NumPy} matrix 
 multiplication, \ie, standard matrix multiplication.
-
-
-\section{Printing Options}
-The format used for printing dense matrices (and the sparse matrices 
-discussed in chapter~\ref{chap:spmatrix}) is controlled
-by the dictionary \member{cvxopt.base.print\_options}.  The dictionary 
-has three keys, \code{'iformat'}, \code{'dformat'}, \code{'zformat'} 
-that control, respectively, how integer, double and complex numbers are 
-printed.  The fields are C printf format strings with default 
-values \code{'5.4e'}\ for \dtc\ and \ztc\ matrices and \code{'5i'}\ for 
-\itc\ matrices.
-\begin{verbatim}
->>> from cvxopt.base import matrix, print_options
->>> print_options
-{'zformat': '5.4e', 'iformat': '5i', 'dformat': '5.4e'}
->>> A = matrix([1., 2., 3.])
->>> print A
-   1.0000e+00
-   2.0000e+00
-   3.0000e+00
->>> print_options['dformat'] = 'f'
->>> print A
-   1.000000
-   2.000000
-   3.000000
->>> print_options['dformat'] = '5.2e'
->>> print A
-   1.00e+00
-   2.00e+00
-   3.00e+00
-\end{verbatim}
diff --git a/doc/base_sparse.tex b/doc/base_sparse.tex
index b50a35b..561068c 100644
--- a/doc/base_sparse.tex
+++ b/doc/base_sparse.tex
@@ -76,11 +76,10 @@ The following code creates a 4 by 4 sparse identity matrix.
 >>> from cvxopt.base import spmatrix
 >>> A = spmatrix(1.0, range(4), range(4))
 >>> print A  
-SIZE: (4,4)
-(0, 0)  1.0000e+00
-(1, 1)  1.0000e+00
-(2, 2)  1.0000e+00
-(3, 3)  1.0000e+00
+[ 1.00e+00     0         0         0    ]
+[    0      1.00e+00     0         0    ]
+[    0         0      1.00e+00     0    ]
+[    0         0         0      1.00e+00]
 \end{verbatim}
 
 \item If \var{x} is a sequence of numbers, a sparse matrix is created 
@@ -97,14 +96,10 @@ As an example, the matrix~(\ref{e-sparse-A}) can be created as follows.
 \begin{verbatim}
 >>> A = spmatrix([2,-1,2,-2,1,4,3], [1,2,0,2,3,2,0], [0,0,1,1,2,3,4])
 >>> print A 
-SIZE: (4,5)
-(1, 0)  2.0000e+00
-(2, 0) -1.0000e+00
-(0, 1)  2.0000e+00
-(2, 1) -2.0000e+00
-(3, 2)  1.0000e+00
-(2, 3)  4.0000e+00
-(0, 4)  3.0000e+00
+[    0      2.00e+00     0         0      3.00e+00]
+[ 2.00e+00     0         0         0         0    ]
+[-1.00e+00 -2.00e+00     0      4.00e+00     0    ]
+[    0         0      1.00e+00     0         0    ]
 \end{verbatim}
 
 \item If \var{x} is a dense matrix, a sparse matrix is created with 
@@ -150,35 +145,27 @@ The following example shows how to construct a sparse block-matrix.
 >>> A = matrix([[1, 2, 0], [2, 1, 2], [0, 2, 1]])
 >>> B = spmatrix([], [], [], (3,3))
 >>> C = spmatrix([3, 4, 5], [0, 1, 2], [0, 1, 2])
->>> print sparse([[A, B], [B, C]])
-SIZE: (6,6)
-(0, 0)  1.0000e+00
-(1, 0)  2.0000e+00
-(0, 1)  2.0000e+00
-(1, 1)  1.0000e+00
-(2, 1)  2.0000e+00
-(1, 2)  2.0000e+00
-(2, 2)  1.0000e+00
-(3, 3)  3.0000e+00
-(4, 4)  4.0000e+00
-(5, 5)  5.0000e+00
+>>> D = sparse([[A, B], [B, C]])
+>>> print D
+[ 1.00e+00  2.00e+00     0         0         0         0    ]
+[ 2.00e+00  1.00e+00  2.00e+00     0         0         0    ]
+[    0      2.00e+00  1.00e+00     0         0         0    ]
+[    0         0         0      3.00e+00     0         0    ]
+[    0         0         0         0      4.00e+00     0    ]
+[    0         0         0         0         0      5.00e+00]
 \end{verbatim}
 
 A matrix with a single block-column can be represented by a single
 list.
 \begin{verbatim}
->>> print sparse([A, C])
-SIZE: (6,3)
-(0, 0)  1.0000e+00
-(1, 0)  2.0000e+00
-(3, 0)  3.0000e+00
-(0, 1)  2.0000e+00
-(1, 1)  1.0000e+00
-(2, 1)  2.0000e+00
-(4, 1)  4.0000e+00
-(1, 2)  2.0000e+00
-(2, 2)  1.0000e+00
-(5, 2)  5.0000e+00
+>>> D = sparse([A, C])
+>>> print D
+[ 1.00e+00  2.00e+00     0    ]
+[ 2.00e+00  1.00e+00  2.00e+00]
+[    0      2.00e+00  1.00e+00]
+[ 3.00e+00     0         0    ]
+[    0      4.00e+00     0    ]
+[    0         0      5.00e+00]
 \end{verbatim}
 \EIT
 \end{funcdesc}
@@ -201,18 +188,14 @@ The following example shows how to construct a sparse block-diagonal matrix.
 >>> A = 3.0
 >>> B = matrix([[1,-2],[-2,1]])
 >>> C = spmatrix([1,1,1,1,1],[0,1,2,0,0,],[0,0,0,1,2])
->>> print spdiag([A, B, C])
-SIZE: (6,6)
-(0, 0)  3.0000e+00
-(1, 1)  1.0000e+00
-(2, 1) -2.0000e+00
-(1, 2) -2.0000e+00
-(2, 2)  1.0000e+00
-(3, 3)  1.0000e+00
-(4, 3)  1.0000e+00
-(5, 3)  1.0000e+00
-(3, 4)  1.0000e+00
-(3, 5)  1.0000e+00
+>>> D = spdiag([A, B, C])
+>>> print D
+[ 3.00e+00     0         0         0         0         0    ]
+[    0      1.00e+00 -2.00e+00     0         0         0    ]
+[    0     -2.00e+00  1.00e+00     0         0         0    ]
+[    0         0         0      1.00e+00  1.00e+00  1.00e+00]
+[    0         0         0      1.00e+00     0         0    ]
+[    0         0         0      1.00e+00     0         0    ]
 \end{verbatim}
 \end{funcdesc}
 
@@ -280,14 +263,10 @@ the matrix
 >>> A = spmatrix([2,1,2,2,1,3,4], [1,2,0,2,3,0,2], [0,0,1,1,2,3,3]) 
 >>> B = spmatrix(sqrt(A.V), A.I, A.J)
 >>> print B
-SIZE: (4,4)
-(1, 0)  1.4142e+00
-(2, 0)  1.0000e+00
-(0, 1)  1.4142e+00
-(2, 1)  1.4142e+00
-(3, 2)  1.0000e+00
-(0, 3)  1.7321e+00
-(2, 3)  2.0000e+00
+[    0      1.41e+00     0      1.73e+00]
+[ 1.41e+00     0         0         0    ]
+[ 1.00e+00  1.41e+00     0      2.00e+00]
+[    0         0      1.00e+00     0    ]
 \end{verbatim}
 
 The next example below illustrates assignments to \member{V}.
@@ -295,41 +274,32 @@ The next example below illustrates assignments to \member{V}.
 >>> from cvxopt.base import spmatrix, matrix
 >>> A = spmatrix(range(5), [0,1,1,2,2], [0,0,1,1,2])
 >>> print A
-SIZE: (3,3)
-(0, 0)  0.0000e+00
-(1, 0)  1.0000e+00
-(1, 1)  2.0000e+00
-(2, 1)  3.0000e+00
-(2, 2)  4.0000e+00
+[ 0.00e+00     0         0    ]
+[ 1.00e+00  2.00e+00     0    ]
+[    0      3.00e+00  4.00e+00]
 >>> B = spmatrix(A.V, A.J, A.I, (4,4))  # transpose and add a zero row and column
 >>> print B
-SIZE: (4,4)
-(0, 0)  0.0000e+00
-(0, 1)  1.0000e+00
-(1, 1)  2.0000e+00
-(1, 2)  3.0000e+00
-(2, 2)  4.0000e+00
+[ 0.00e+00  1.00e+00     0         0    ]
+[    0      2.00e+00  3.00e+00     0    ]
+[    0         0      4.00e+00     0    ]
+[    0         0         0         0    ]
 >>> print matrix(B)
- 0.0000e+00   1.0000e+00   0.0000e+00   0.0000e+00
- 0.0000e+00   2.0000e+00   3.0000e+00   0.0000e+00
- 0.0000e+00   0.0000e+00   4.0000e+00   0.0000e+00
- 0.0000e+00   0.0000e+00   0.0000e+00   0.0000e+00
->>> B.V[:] = 1., 7., 8., 6., 4.   # assign new values to nonzero entries
+[ 0.00e+00  1.00e+00  0.00e+00  0.00e+00]
+[ 0.00e+00  2.00e+00  3.00e+00  0.00e+00]
+[ 0.00e+00  0.00e+00  4.00e+00  0.00e+00]
+[ 0.00e+00  0.00e+00  0.00e+00  0.00e+00]
+>>> B.V = matrix([1., 7., 8., 6., 4.])   # assign new values to nonzero entries
 >>> print B
-SIZE: (4,4)
-(0, 0)  1.0000e+00
-(0, 1)  7.0000e+00
-(1, 1)  8.0000e+00
-(1, 2)  6.0000e+00
-(2, 2)  4.0000e+00
+[ 1.00e+00  7.00e+00     0         0    ]
+[    0      8.00e+00  6.00e+00     0    ]
+[    0         0      4.00e+00     0    ]
+[    0         0         0         0    ]
 >>> B.V += 1.0   # add 1 to the nonzero entries
 >>> print B
-SIZE: (4,4)
-(0, 0)  2.0000e+00
-(0, 1)  8.0000e+00
-(1, 1)  9.0000e+00
-(1, 2)  7.0000e+00
-(2, 2)  5.0000e+00
+[ 2.00e+00  8.00e+00     0         0    ]
+[    0      9.00e+00  7.00e+00     0    ]
+[    0         0      5.00e+00     0    ]
+[    0         0         0         0    ]
 \end{verbatim}
 
 The \member{V}, \member{I} and \member{J}  attributes can be used for 
@@ -351,12 +321,9 @@ A sparse matrix can be created from this file as follows.
 >>> J = matrix(0, (5,1));  J.fromfile(f)  
 >>> B = spmatrix(V, I, J)
 >>> print B
-SIZE: (3,3)
-(0, 0)  0.0000e+00
-(1, 0)  1.0000e+00
-(1, 1)  2.0000e+00
-(2, 1)  3.0000e+00
-(2, 2)  4.0000e+00
+[ 0.00e+00     0         0    ]
+[ 1.00e+00  2.00e+00     0    ]
+[    0      3.00e+00  4.00e+00]
 \end{verbatim}
 
 Note that the  \module{pickle} module provides a convenient alternative 
@@ -469,19 +436,13 @@ Sparse matrices can be indexed the same way as dense matrices
 >>> from cvxopt.base import spmatrix
 >>> A = spmatrix([0,2,-1,2,-2,1], [0,1,2,0,2,1], [0,0,0,1,1,2]) 
 >>> print A[:,[0,1]]
-SIZE: (3,2)
-(0, 0)  0.0000e+00
-(1, 0)  2.0000e+00
-(2, 0) -1.0000e+00
-(0, 1)  2.0000e+00
-(2, 1) -2.0000e+00
+[ 0.00e+00  2.00e+00]
+[ 2.00e+00     0    ]
+[-1.00e+00 -2.00e+00]
 >>> B = spmatrix([0,2*1j,0,-2], [1,2,1,2], [0,0,1,1,])
 >>> print B[-2:,-2:]
-SIZE: (2,2)
-(0, 0)  0.0000e+00-j0.0000e+00
-(1, 0)  2.0000e+00-j0.0000e+00
-(0, 1)  0.0000e+00-j0.0000e+00
-(1, 1)  0.0000e+00-j2.0000e+00
+[ 0.00e+00-j0.00e+00  0.00e+00-j0.00e+00]
+[ 0.00e+00+j2.00e+00 -2.00e+00-j0.00e+00]
 \end{verbatim}
 
 An indexed sparse matrix \code{\var{A}[\var{I}]} or 
@@ -501,40 +462,25 @@ We continue the example above.
 >>> C = spmatrix([10,-20,30], [0,2,1], [0,0,1])
 >>> A[:,0] = C[:,0]
 >>> print A
-SIZE: (3,3)
-(0, 0)  1.0000e+01
-(2, 0) -2.0000e+01
-(0, 1)  2.0000e+00
-(2, 1) -2.0000e+00
-(1, 2)  1.0000e+00
+[ 1.00e+01  2.00e+00     0    ]
+[    0         0      1.00e+00]
+[-2.00e+01 -2.00e+00     0    ]
 >>> D = matrix(range(6), (3,2))
 >>> A[:,0] = D[:,0]
 >>> print A
-SIZE: (3,3)
-(0, 0)  0.0000e+00
-(1, 0)  1.0000e+00
-(2, 0)  2.0000e+00
-(0, 1)  2.0000e+00
-(2, 1) -2.0000e+00
-(1, 2)  1.0000e+00
+[ 0.00e+00  2.00e+00     0    ]
+[ 1.00e+00     0      1.00e+00]
+[ 2.00e+00 -2.00e+00     0    ]
 >>> A[:,0] = 1
 >>> print A
-SIZE: (3,3)
-(0, 0)  1.0000e+00
-(1, 0)  1.0000e+00
-(2, 0)  1.0000e+00
-(0, 1)  2.0000e+00
-(2, 1) -2.0000e+00
-(1, 2)  1.0000e+00
+[ 1.00e+00  2.00e+00     0    ]
+[ 1.00e+00     0      1.00e+00]
+[ 1.00e+00 -2.00e+00     0    ]
 >>> A[:,0] = 0
 >>> print A
-TYPE: (3,3)
-(0, 0)  0.0000e+00
-(1, 0)  0.0000e+00
-(2, 0)  0.0000e+00
-(0, 1)  2.0000e+00
-(2, 1) -2.0000e+00
-(1, 2)  1.0000e+00
+[ 0.00e+00  2.00e+00     0    ]
+[ 0.00e+00     0      1.00e+00]
+[ 0.00e+00 -2.00e+00     0    ]
 \end{verbatim}
 
 
@@ -584,14 +530,10 @@ matrix~(\ref{e-spA-example}).
 >>> A = spmatrix([2,1,2,2,1,3,4], [1,2,0,2,3,0,2], [0,0,1,1,2,3,3]) 
 >>> B = spmatrix(map(lambda x: x**2, A), A.I, A.J)
 >>> print B
-SIZE: (4,4)
-(1, 0)  4.0000e+00
-(2, 0)  1.0000e+00
-(0, 1)  4.0000e+00
-(2, 1)  4.0000e+00
-(3, 2)  1.0000e+00
-(0, 3)  9.0000e+00
-(2, 3)  1.6000e+01
+[    0      4.00e+00     0      9.00e+00]
+[ 4.00e+00     0         0         0    ]
+[ 1.00e+00  4.00e+00     0      1.60e+01]
+[    0         0      1.00e+00     0    ]
 \end{verbatim}
 
 The expression \samp{\var{x} in \var{A}} returns \True\  if a nonzero
@@ -720,12 +662,9 @@ B = \left[ \begin{array}{ccc}
 >>> C = spmatrix([], [], [], size=(3,3))
 >>> gemm(A, B, C, transA='T')
 >>> print C
-SIZE: (3,3)
-(0, 0)  4.0000e+00
-(2, 0)  2.0000e+00
-(1, 1)  2.0000e+00
-(0, 2)  2.0000e+00
-(2, 2)  2.0000e+00
+[ 4.00e+00     0      2.00e+00]
+[    0      2.00e+00     0    ]
+[ 2.00e+00     0      2.00e+00]
 \end{verbatim}
 Now suppose we want to replace \var{C}  with
 \[
@@ -742,10 +681,7 @@ sparsity pattern of the result is known beforehand.
 >>> D = spmatrix([3,4,1,1,-2], [1,3,0,2,1], [0,0,1,1,2])
 >>> gemm(A, D, C, transA='T', partial=True)
 >>> print C
-SIZE: (3,3)
-(0, 0)  7.0000e+00
-(2, 0)  3.0000e+00
-(1, 1)  2.0000e+00
-(0, 2) -2.0000e+00
-(2, 2) -2.0000e+00
+[ 7.00e+00     0     -2.00e+00]
+[    0      2.00e+00     0    ]
+[ 3.00e+00     0     -2.00e+00]
 \end{verbatim}
diff --git a/doc/blas.tex b/doc/blas.tex
index 4408b6f..8baf421 100644
--- a/doc/blas.tex
+++ b/doc/blas.tex
@@ -586,9 +586,9 @@ with the vector {\it x} = (1,-1,2,-2).
 >>> y = matrix(0., (3,1))
 >>> gbmv(A, 3, 1, x, y)
 >>> print y
--5.0000e+00
- 1.2000e+01
--1.0000e+00
+[-5.00e+00]
+[ 1.20e+01]
+[-1.00e+00]
 \end{verbatim}
 
 The following example illustrates the use of \function{tbsv()}.
@@ -599,10 +599,10 @@ The following example illustrates the use of \function{tbsv()}.
 >>> x = matrix(1.0, (4,1))
 >>> tbsv(A, x)  # x := diag(A)^{-1}*x
 >>> print x
--1.6667e-01
- 2.0000e-01
--1.0000e+00
- 5.0000e-01
+[-1.67e-01]
+[ 2.00e-01]
+[-1.00e+00]
+[ 5.00e-01]
 \end{verbatim}
 
 
diff --git a/doc/coneprog.tex b/doc/coneprog.tex
index 63d93ce..1f9f096 100644
--- a/doc/coneprog.tex
+++ b/doc/coneprog.tex
@@ -189,32 +189,32 @@ As an example we solve the problem
 >>> h = matrix( [ -3., 5.,  12.,  -2., -14., -13., 10.,  0.,  0.,  0.,  68., -30., -19., -30.,  99.,  23., -19.,   23.,  10.] )
 >>> dims = {'l': 2, 'q': [4, 4], 's': [3]}
 >>> sol = solvers.conelp(c, G, h, dims)
->>> print sol['status']
-optimal
+>>> sol['status']
+'optimal'
 >>> print sol['x']
-  -1.2209e+00
-   9.6633e-02
-   3.5775e+00
+[-1.22e+00]
+[ 9.66e-02]
+[ 3.58e+00]
 >>> print sol['z']
-   9.2985e-02
-   2.0401e-08
-   2.3534e-01
-   1.3339e-01
-  -4.7354e-02
-   1.8801e-01
-   2.7871e-08
-   1.8544e-09
-  -6.3156e-10
-  -7.5921e-09
-   1.2558e-01
-   8.7775e-02
-  -8.6652e-02
-   8.7775e-02
-   6.1349e-02
-  -6.0564e-02
-  -8.6652e-02
-  -6.0564e-02
-   5.9790e-02
+[ 9.30e-02]
+[ 2.04e-08]
+[ 2.35e-01]
+[ 1.33e-01]
+[-4.74e-02]
+[ 1.88e-01]
+[ 2.79e-08]
+[ 1.85e-09]
+[-6.32e-10]
+[-7.59e-09]
+[ 1.26e-01]
+[ 8.78e-02]
+[-8.67e-02]
+[ 8.78e-02]
+[ 6.13e-02]
+[-6.06e-02]
+[-8.67e-02]
+[-6.06e-02]
+[ 5.98e-02]
 \end{verbatim}
 
 Only the entries of \var{G} and \var{h} defining the lower triangular 
@@ -282,8 +282,8 @@ As a simple example we solve the LP
 >>> h = matrix([3., 3., 0., 0.])
 >>> sol = solvers.lp(c, G, h)
 >>> print sol['x']
-   1.0000e-00
-   1.0000e-00
+[ 1.00e+00]
+[ 1.00e+00]
 \end{verbatim}
 
 \section{Second-Order Cone Programming} \label{s-socpsolver}
@@ -405,18 +405,18 @@ As an example, we solve  the second-order cone program
 >>> sol['status']
 optimal
 >>> print sol['x']
-  -5.0150e+00
-  -5.7670e+00
-  -8.5219e+00
+[-5.02e+00]
+[-5.77e+00]
+[-8.52e+00]
 >>> print sol['zq'][0]
-   1.3423e+00
-  -7.6286e-02
-  -1.3401e+00
+[ 1.34e+00]
+[-7.63e-02]
+[-1.34e+00]
 >>> print sol['zq'][1]
-   1.0185e+00
-   4.0234e-01
-   7.7996e-01
-  -5.1681e-01
+[ 1.02e+00]
+[ 4.02e-01]
+[ 7.80e-01]
+[-5.17e-01]
 \end{verbatim}
 
 
@@ -574,16 +574,16 @@ We illustrate the calling sequence with a small example.
 >>> h += [ matrix([[14., 9., 40.], [9., 91., 10.], [40., 10., 15.]]) ]
 >>> sol = solvers.sdp(c, Gs=G, hs=h)  
 >>> print sol['x']
-  -3.6767e-01
-   1.8983e+00
-  -8.8755e-01
+[-3.68e-01]
+[ 1.90e+00]
+[-8.88e-01]
 >>> print sol['zs'][0]
-   3.9611e-03  -4.3384e-03
-  -4.3384e-03   4.7516e-03
+[ 3.96e-03 -4.34e-03]
+[-4.34e-03  4.75e-03]
 >>> print sol['zs'][1]
-   5.5801e-02  -2.4091e-03   2.4215e-02
-  -2.4091e-03   1.0402e-04  -1.0454e-03
-   2.4215e-02  -1.0454e-03   1.0508e-02
+[ 5.58e-02 -2.41e-03  2.42e-02]
+[-2.41e-03  1.04e-04 -1.05e-03]
+[ 2.42e-02 -1.05e-03  1.05e-02]
 \end{verbatim}
 Only the entries in \var{Gs} and \var{hs} that correspond to lower 
 triangular entries need to be provided, so in the example \var{h} and 
diff --git a/doc/cvxopt.tex b/doc/cvxopt.tex
index 6dcd337..85b8ace 100644
--- a/doc/cvxopt.tex
+++ b/doc/cvxopt.tex
@@ -1,7 +1,6 @@
 \documentclass{book}
-%\usepackage{url,graphicx}
-%\usepackage{html,graphicx}
 \usepackage{graphicx}
+%\usepackage{html,graphicx}
 
 \parindent 0pt
 
@@ -53,7 +52,6 @@
     \begin{list}{}{}\item[]}{\end{list}}
 \newenvironment{methoddesc}[1]{\par{\bf #1}()%
     \begin{list}{}{}\item[]}{\end{list}}
-%\newenvironment{seealso}{\par{\bf See also:}\begin{itemize}\item}{\end{itemize}}
 \newcommand{\seetext}[1]{#1} 
 \newcommand{\htmladdnormallink}[2]{\Link[#2]{}{}{#1}\EndLink} 
 \newcommand{\ulink}[2]{\htmladdnormallink{#1}{#2}} 
@@ -79,7 +77,7 @@
 
 \title{CVXOPT User's Guide} 
 \author{Joachim Dahl \& Lieven Vandenberghe}
-\date{Release 0.9.1 -- November 23, 2007} 
+\date{Release 0.9.2 -- December 27, 2007} 
 
 \begin{document}
 \Configure{crosslinks*}{next}{prev}{up}{}
@@ -143,5 +141,7 @@ Availability: \ulink{www.cise.ufl.edu/research/sparse}
 \input{coneprog}
 \input{solvers}
 \input{modeling}
+\appendix
 \input{c-api}
+\input{printing}
 \end{document}
diff --git a/doc/intro.tex b/doc/intro.tex
index df579af..613445a 100644
--- a/doc/intro.tex
+++ b/doc/intro.tex
@@ -10,7 +10,7 @@ optimization applications straightforward by building on Python's
 extensive standard library and on the strengths of Python as a 
 high-level programming language.  
 
-Release 0.9.1 of CVXOPT includes routines for basic linear algebra 
+Release 0.9.2 of CVXOPT includes routines for basic linear algebra 
 calculations, interfaces to efficient libraries for solving dense and 
 sparse linear equations, convex optimization solvers written in Python,
 interfaces to a few other optimization libraries, 
@@ -20,12 +20,11 @@ These components are organized in different modules.
 \item[\module{cvxopt.base}] This module defines a Python type
  \mtrx\ for storing and manipulating dense matrices, 
  a Python type \spmtrx\ for storing and manipulating sparse 
- matrices, and routines for sparse matrix-vector and matrix-matrix 
+ matrices, routines for generating sparse dense matrices 
+ (see section~\ref{s-random}), and routines 
+ for sparse matrix-vector and matrix-matrix 
  multiplication (see chapters~\ref{chap:matrix} 
  and~\ref{chap:spmatrix}).
-\item[\module{cvxopt.random}] Routines for generating random matrices 
- with uniformly or normally distributed entries 
- (see section~\ref{s-random}).
 \item[\module{cvxopt.blas}] Interface to most of the double-precision 
  real and complex BLAS (chapter~\ref{chap:blas}).
 \item[\module{cvxopt.lapack}] Interface to the dense double-precision 
@@ -48,6 +47,8 @@ These components are organized in different modules.
 \item[\module{cvxopt.info}] Defines a string \code{version} with
  the version number of the CVXOPT installation and a function 
  \function{license()} that prints the CVXOPT license.  
+\item[\module{cvxopt.printing}] Contains functions and parameters that
+ control how matrices are formatted. 
 \end{description}
 The modules are described in detail in this manual and in the 
 on-line Python help facility \program{pydoc}.  Several example scripts 
diff --git a/doc/lapack.tex b/doc/lapack.tex
index 33ae3be..c1534e2 100644
--- a/doc/lapack.tex
+++ b/doc/lapack.tex
@@ -100,8 +100,7 @@ In the following example we compute
 for randomly generated problem data, factoring the coefficient matrix 
 once.
 \begin{verbatim}
->>> from cvxopt.base import matrix
->>> from cvxopt.random import normal
+>>> from cvxopt.base import matrix, normal
 >>> from cvxopt.lapack import gesv, getrs
 >>> n = 10
 >>> A = normal(n,n)
@@ -190,10 +189,10 @@ As an example, we solve a linear equation with
 >>> x = matrix(1.0, (4,1))
 >>> gbsv(A, kl, x)
 >>> print x
-   7.1429e-02
-   4.6429e-01
-  -2.1429e-01
-  -1.0714e-01
+[ 7.14e-02]
+[ 4.64e-01]
+[-2.14e-01]
+[-1.07e-01]
 \end{verbatim}
 The code below illustrates how one can reuse the factorization returned
 by \function{gbsv()}. 
@@ -203,18 +202,18 @@ by \function{gbsv()}.
 >>> ipiv = matrix(0, (n,1))
 >>> x = matrix(1.0, (4,1))
 >>> gbsv(Ac, kl, x, ipiv)                 # solves A*x = 1
->>> print x                 
-   7.1429e-02
-   4.6429e-01
-  -2.1429e-01
-  -1.0714e-01
+>>> print x
+[ 7.14e-02]
+[ 4.64e-01]
+[-2.14e-01]
+[-1.07e-01]
 >>> x = matrix(1.0, (4,1))
 >>> gbtrs(Ac, kl, ipiv, x, trans='T')     # solve A^T*x = 1
 >>> print x
-   7.1429e-02
-   2.3810e-02
-   1.4286e-01
-  -2.3810e-02
+[ 7.14e-02]
+[ 2.38e-02]
+[ 1.43e-01]
+[-2.38e-02]
 \end{verbatim}
 An alternative method uses \function{gbtrf()} for the factorization.
 \begin{verbatim}
@@ -223,17 +222,17 @@ An alternative method uses \function{gbtrf()} for the factorization.
 >>> x = matrix(1.0, (4,1))
 >>> gbtrs(Ac, kl, ipiv, x)                # solve A^T*x = 1
 >>> print x                 
-   7.1429e-02
-   4.6429e-01
-  -2.1429e-01
-  -1.0714e-01
+[ 7.14e-02]
+[ 4.64e-01]
+[-2.14e-01]
+[-1.07e-01]
 >>> x = matrix(1.0, (4,1))
 >>> gbtrs(Ac, kl, ipiv, x, trans='T')     # solve A^T*x = 1
 >>> print x
-   7.1429e-02
-   2.3810e-02
-   1.4286e-01
-  -2.3810e-02
+[ 7.14e-02]
+[ 2.38e-02]
+[ 1.43e-01]
+[-2.38e-02]
 \end{verbatim}
 
 The following functions can be used for tridiagonal matrices They use a 
@@ -343,8 +342,7 @@ As an example, we use \function{posv()} to solve the linear system
 by block-elimination. 
 We first pick a random problem.
 \begin{verbatim}
->>> from cvxopt.base import matrix, div
->>> from cvxopt.random import normal, uniform
+>>> from cvxopt.base import matrix, div, normal, uniform
 >>> from cvxopt.blas import syrk, gemv
 >>> from cvxopt.lapack import posv
 >>> m, n = 100, 50  
diff --git a/doc/modeling.tex b/doc/modeling.tex
index 3c10586..ce5817d 100644
--- a/doc/modeling.tex
+++ b/doc/modeling.tex
@@ -58,14 +58,14 @@ a
 None
 >>> x.value = matrix([1.,2.,3.])
 >>> print x.value
- 1.0000e+00
- 2.0000e+00
- 3.0000e+00
+[ 1.00e+00]
+[ 2.00e+00]
+[ 3.00e+00]
 >>> x.value = 1
 >>> print x.value
- 1.0000e+00
- 1.0000e+00
- 1.0000e+00
+[ 1.00e+00]
+[ 1.00e+00]
+[ 1.00e+00]
 \end{verbatim}
 
 
@@ -187,15 +187,15 @@ The functions \var{f} and \var{g} are given by
 >>> print g
 affine function of length 2
 constant term:
- 1.3000e+01
- 1.7000e+01
+[ 1.30e+01]
+[ 1.70e+01]
 linear term: linear function of length 2
 coefficient of variable(2,'y'):
- 2.0000e+00   4.0000e+00
- 3.0000e+00   5.0000e+00
+[ 2.00e+00  4.00e+00]
+[ 3.00e+00  5.00e+00]
 coefficient of variable(1,'x'):
- 8.0000e+00
- 1.2000e+01
+[ 8.00e+00]
+[ 1.20e+01]
 \end{verbatim}
 
 \begin{description}
@@ -220,27 +220,22 @@ operation is an affine function.
 >>> x = variable(4,'x')
 >>> f = x[::2]
 >>> print f 
->>> linear function of length 2
+linear function of length 2
 linear term: linear function of length 2
 coefficient of variable(4,'x'):
-TYPE: general
-SIZE: (2,4)
-(0, 0)  1.0000e+00
-(1, 2)  1.0000e+00
+[ 1.00e+00     0         0         0    ]
+[    0         0      1.00e+00     0    ]
 >>> y = variable(3,'x')
 >>> g = matrix(range(12),(3,4),'d')*x - 3*y + 1
 >>> print g[0] + g[2]
-affine function of length 1 
+affine function of length 1
 constant term:
- 2.0000e+00
+[ 2.00e+00]
 linear term: linear function of length 1
 coefficient of variable(4,'x'):
- 2.0000e+00   8.0000e+00   1.4000e+01   2.0000e+01
-coefficient of variable(3,'y'):
-TYPE: general
-SIZE: (1,3)
-(0, 0) -3.0000e+00
-(0, 2) -3.0000e+00
+[ 2.00e+00  8.00e+00  1.40e+01  2.00e+01]
+coefficient of variable(3,'x'):
+[-3.00e+00     0     -3.00e+00]
 \end{verbatim}
 
 
@@ -544,22 +539,22 @@ As an example we solve the LP
 >>> c4 = ( y >= 0 ) 
 >>> lp1 = op(-4*x-5*y, [c1,c2,c3,c4]) 
 >>> lp1.solve()
->>> print lp1.status
-optimal
+>>> lp1.status
+'optimal'
 >>> print lp1.objective.value()
--9.0000e+00
+[-9.00e+00]
 >>> print x.value
- 1.0000e-00
+[ 1.00e+00]
 >>> print y.value
- 1.0000e-00
+[ 1.00e+00]
 >>> print c1.multiplier.value
- 1.0000e-00
+[ 1.00e+00]
 >>> print c2.multiplier.value
- 2.0000e-00
+[ 2.00e+00]
 >>> print c3.multiplier.value
- 8.8912e-09
+[ 2.87e-08]
 >>> print c4.multiplier.value
- 9.8567e-09
+[ 2.80e-08]
 \end{verbatim}
 
 We can solve the same LP in  matrix form as follows.
@@ -572,15 +567,15 @@ We can solve the same LP in  matrix form as follows.
 >>> lp2 = op(dot(c,x), ineq)
 >>> lp2.solve()
 >>> print lp2.objective.value()
--9.0000e+00
+[-9.00e+00]
 >>> print x.value
- 1.0000e-00
- 1.0000e-00
+[ 1.00e+00]
+[ 1.00e+00]
 >>> print ineq.multiplier.value
- 1.0000e+00
- 2.0000e+00
- 8.8912e-09
- 9.8567e-09
+[1.00e+00]
+[2.00e+00]
+[2.87e-08]
+[2.80e-08]
 \end{verbatim}
 
 The \pytype{op} class also includes two methods for writing and reading
@@ -633,7 +628,7 @@ package for plotting the histograms of the residual vectors for the
 two solutions.  It generates the figure shown below.
 
 \begin{verbatim}
-from cvxopt.random import normal
+from cvxopt.base import normal
 from cvxopt.modeling import variable, op, max, sum
 import pylab
 
@@ -707,7 +702,7 @@ the equivalent LP
 for randomly generated data.
 
 \begin{verbatim}
-from cvxopt.random import normal, uniform
+from cvxopt.base import normal, uniform
 from cvxopt.modeling import variable, dot, op, sum 
 
 m, n = 500, 100
diff --git a/doc/printing.tex b/doc/printing.tex
new file mode 100644
index 0000000..276b008
--- /dev/null
+++ b/doc/printing.tex
@@ -0,0 +1,115 @@
+\chapter{Matrix Formatting (\module{cvxopt.printing})}
+\label{chap:printing}
+
+This appendix describes ways to customize the formatting of CVXOPT matrices.
+
+As with other Python objects, the functions 
+\function{repr()} and \function{str()} return strings with printable
+representations of matrices.  
+The command \code{"print A"} calls the function \function{str(A)}, whereas
+the command \code{"A"} calls \function{repr(A)}.
+The following example illustrates the default formatting of dense matrices.
+\begin{verbatim}
+>>> from cvxopt import base 
+>>> A = base.matrix(range(50), (5,10), 'd')
+>>> A  
+<5x10 matrix, tc='d'>
+>>> print A
+[ 0.00e+00  5.00e+00  1.00e+01  1.50e+01  2.00e+01  2.50e+01  3.00e+01 ... ]
+[ 1.00e+00  6.00e+00  1.10e+01  1.60e+01  2.10e+01  2.60e+01  3.10e+01 ... ]
+[ 2.00e+00  7.00e+00  1.20e+01  1.70e+01  2.20e+01  2.70e+01  3.20e+01 ... ]
+[ 3.00e+00  8.00e+00  1.30e+01  1.80e+01  2.30e+01  2.80e+01  3.30e+01 ... ]
+[ 4.00e+00  9.00e+00  1.40e+01  1.90e+01  2.40e+01  2.90e+01  3.40e+01 ... ]
+\end{verbatim}
+The format is parameterized by the dictionary \member{options} in the 
+module \module{cvxopt.printing}.  
+The parameters \code{options['iformat']} and \code{options['dformat']}
+determine, respectively, how integer and double/complex numbers are 
+printed.  The entries are Python format strings with default 
+values \code{'\% .2e'}\ for \dtc\ and \ztc\ matrices and \code{'\% i'}\ for 
+\itc\ matrices. 
+The parameters \code{options['width']} and \code{options['height']}
+specify the maximum number of columns and rows that are shown. 
+If \code{'width'} is set to a negative value, all columns are displayed.
+If \code{'height'} is set to a negative value, all rows are displayed.
+The default values of \code{'width'} and \code{'height'} are 7 and -1,
+respectively.
+\begin{verbatim}
+>>> from cvxopt import printing
+>>> printing.options
+{'width': 7, 'dformat': '% .2e', 'iformat': '% i', 'height': -1}
+>>> printing.options['dformat'] = '%.1f'
+>>> print_options['width'] = -1
+>>> print A
+[ 0.0  5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0]
+[ 1.0  6.0 11.0 16.0 21.0 26.0 31.0 36.0 41.0 46.0]
+[ 2.0  7.0 12.0 17.0 22.0 27.0 32.0 37.0 42.0 47.0]
+[ 3.0  8.0 13.0 18.0 23.0 28.0 33.0 38.0 43.0 48.0]
+[ 4.0  9.0 14.0 19.0 24.0 29.0 34.0 39.0 44.0 49.0]
+\end{verbatim}
+
+In order to make the built-in Python functions \function{repr()} and 
+\function{str()} accessible for further customization, two functions
+are provided in \module{cvxopt.base}.  
+The function \function{base.matrix_repr()} is used when \function{repr()}
+is called with a matrix argument;
+and \function{base.matrix_str()} is used when \function{str()}
+is called with a matrix argument.  By default, the functions are set to
+\function{printing.matrix_repr_default()} and
+\function{printing.matrix_str_default()}, respectively,
+but they can be redefined to any other Python functions. 
+For example, if we prefer \code{"A"} to return the same output
+as \code{"print A"}, we can simply redefine \function{base.matrix_repr()} 
+as shown below.
+\begin{verbatim}
+>>> from cvxopt import base, printing
+>>> A = base.matrix(range(4), (2,2), 'd')
+>>> A
+<2x2 matrix, tc='d'>
+>>> base.matrix_repr = printing.matrix_str_default
+>>> A
+[ 0.00e+00  2.00e+00]
+[ 1.00e+00  3.00e+00]
+\end{verbatim}
+
+The formatting for sparse matrices is similar.  
+The functions \function{repr()} and \function{str()} for sparse
+matrices are \function{base.spmatrix_repr()} 
+and \function{base.spmatrix_str()}, respectively.
+By default, they are set to \function{printing.spmatrix_repr_default()}
+and \function{printing.spmatrix_repr_str()}.
+
+\begin{verbatim}
+>>> from cvxopt import base, printing 
+>>> A = base.spmatrix(range(5), range(5), range(5), (5,10) )
+>>> A
+<5x10 matrix, tc='d', nnz=5>
+>>> print A
+[ 0.00e+00     0         0         0         0         0         0     ... ]
+[    0      1.00e+00     0         0         0         0         0     ... ]
+[    0         0      2.00e+00     0         0         0         0     ... ]
+[    0         0         0      3.00e+00     0         0         0     ... ]
+[    0         0         0         0      4.00e+00     0         0     ... ]
+
+>>> base.spmatrix_repr = printing.spmatrix_str_default
+>>> A
+[ 0.00e+00     0         0         0         0         0         0     ... ]
+[    0      1.00e+00     0         0         0         0         0     ... ]
+[    0         0      2.00e+00     0         0         0         0     ... ]
+[    0         0         0      3.00e+00     0         0         0     ... ]
+[    0         0         0         0      4.00e+00     0         0     ... ]
+\end{verbatim}
+
+As can be seen from the example, the default behaviour is to print
+the entire matrix including structural zeros. An alternative triplet 
+printing style is defined in \function{printing.spmatrix_str_triplet}. 
+\begin{verbatim}
+>>> base.spmatrix_str = printing.spmatrix_str_triplet
+>>> print A
+(0,0)  0.00e+00
+(1,1)  1.00e+00
+(2,2)  2.00e+00
+(3,3)  3.00e+00
+(4,4)  4.00e+00
+
+\end{verbatim}
diff --git a/doc/solvers.tex b/doc/solvers.tex
index 61c9023..c7f0416 100644
--- a/doc/solvers.tex
+++ b/doc/solvers.tex
@@ -275,9 +275,9 @@ h = matrix([1.0, 0.0, 0.0, 0.0, 20., 10., 40., 10., 80., 10., 40., 10., 15.])
 dims = {'l': 0, 'q': [4], 's':  [3]}
 sol = solvers.cp(F, G, h, dims)
 print sol['x']
-   4.1132e-01
-   5.5885e-01
-  -7.2007e-01
+[ 4.11e-01]
+[ 5.59e-01]
+[-7.20e-01]
 \end{verbatim}
 \end{description}
 
diff --git a/doc/spsolvers.tex b/doc/spsolvers.tex
index 682c4dd..b535c54 100644
--- a/doc/spsolvers.tex
+++ b/doc/spsolvers.tex
@@ -60,10 +60,10 @@ As an example we consider the matrix
 >>> A = spmatrix([10,3,5,-2,5,2], [0,2,1,2,2,3], [0,0,1,1,2,3])
 >>> P = amd.order(A)
 >>> print P
- 1
- 0
- 2
- 3
+[ 1]
+[ 0]
+[ 2]
+[ 3]
 \end{verbatim}
 
 \section{General Linear Equations (\module{cvxopt.umfpack})} 
@@ -116,11 +116,11 @@ A = \left[\begin{array}{rrrrr}
 >>> B = matrix(1.0, (5,1))
 >>> umfpack.linsolve(A,B)
 >>> print B
- 5.7895e-01
--5.2632e-02
- 1.0000e+00
- 1.9737e+00
--7.8947e-01
+[ 5.79e-01]
+[-5.26e-02]
+[ 1.00e+00]
+[ 1.97e+00]
+[-7.89e-01]
 \end{verbatim}
 The function \function{umfpack.linsolve()} is equivalent to the 
 following three functions called in sequence.  
@@ -197,11 +197,11 @@ The following code computes
 >>> umfpack.solve(B, FB, x)
 >>> umfpack.solve(A, FA, x, trans='T')
 >>> print x
- 5.8065e-01
--2.3660e-01
- 1.6280e+00
- 8.0656e+00
--1.3075e-01
+[ 5.81e-01]
+[-2.37e-01]
+[ 1.63e+00]
+[ 8.07e+00]
+[-1.31e-01]
 \end{verbatim}
 
 \section{Positive Definite Linear Equations (\module{cvxopt.cholmod})} 
@@ -253,10 +253,10 @@ As an  example, we solve
 >>> X = matrix(range(8), (4,2), 'd')
 >>> cholmod.linsolve(A,X)
 >>> print X
--1.4634e-01   4.8780e-02
- 1.3333e+00   4.0000e+00
- 4.8780e-01   1.1707e+00
- 2.8333e+00   7.5000e+00
+[-1.46e-01  4.88e-02]
+[ 1.33e+00  4.00e+00]
+[ 4.88e-01  1.17e+00]
+[ 2.83e+00  7.50e+00]
 \end{verbatim}
 
 \begin{funcdesc}{splinsolve}{A, B\optional{, p=\None\optional{, 
@@ -271,15 +271,10 @@ in~(\ref{e-A-pd}) as a sparse matrix.
 \begin{verbatim}
 >>> X = cholmod.splinsolve(A, spmatrix(1.0,range(4),range(4)))
 >>> print X
-SIZE: (4,4)
-(0, 0)  1.2195e-01
-(2, 0) -7.3171e-02
-(1, 1)  3.3333e-01
-(3, 1)  3.3333e-01
-(0, 2) -7.3171e-02
-(2, 2)  2.4390e-01
-(1, 3)  3.3333e-01
-(3, 3)  8.3333e-01
+[ 1.22e-01     0     -7.32e-02     0    ]
+[    0      3.33e-01     0      3.33e-01]
+[-7.32e-02     0      2.44e-01     0    ]
+[    0      3.33e-01     0      8.33e-01]
 \end{verbatim}
 
 The functions \function{linsolve()} and \function{splinsolve()} are
@@ -376,10 +371,10 @@ For the same example as above:
 >>> cholmod.numeric(A,F)
 >>> cholmod.solve(F,X)
 >>> print X
--1.4634e-01   4.8780e-02
- 1.3333e+00   4.0000e+00
- 4.8780e-01   1.1707e+00
- 2.8333e+00   7.5000e+00
+[-1.46e-01  4.88e-02]
+[ 1.33e+00  4.00e+00]
+[ 4.88e-01  1.17e+00]
+[ 2.83e+00  7.50e+00]
 \end{verbatim}
 
 \begin{funcdesc}{diag}{F}
diff --git a/examples/book/chap6/penalties b/examples/book/chap6/penalties
index 6871db0..b1c6e07 100755
--- a/examples/book/chap6/penalties
+++ b/examples/book/chap6/penalties
@@ -6,14 +6,14 @@
 # The problem data are not the same as in the book figure.
 
 import pylab
-from cvxopt import random, lapack, solvers
+from cvxopt import base, lapack, solvers
 from cvxopt.base import matrix, spdiag, log, div
 from cvxopt.modeling import variable, op, max, sum 
 solvers.options['show_progress'] = 0
 
 m, n = 100, 30
-A = random.normal(m,n)
-b = random.normal(m,1)
+A = base.normal(m,n)
+b = base.normal(m,1)
 b /= (1.1 * max(abs(b)))   # Make x = 0 feasible for log barrier.
 
 
diff --git a/examples/book/chap6/robls b/examples/book/chap6/robls
index ffe497f..2de7b97 100755
--- a/examples/book/chap6/robls
+++ b/examples/book/chap6/robls
@@ -4,7 +4,7 @@
 # Stochastic and worst-case robust approximation.
 
 from math import pi
-from cvxopt import random, blas, lapack, solvers
+from cvxopt import base, blas, lapack, solvers
 from cvxopt.base import matrix, spmatrix, mul, cos, sin, sqrt
 import pylab
 from pickle import load
@@ -121,8 +121,8 @@ lapack.posv(S, xtik)
 xwc = wcls(A, Ap, b)
 
 notrials = 100000
-r = sqrt(random.uniform(1,notrials))
-theta = 2.0 * pi * random.uniform(1,notrials)
+r = sqrt(base.uniform(1,notrials))
+theta = 2.0 * pi * base.uniform(1,notrials)
 u = matrix(0.0, (2,notrials))
 u[0,:] = mul(r, cos(theta))
 u[1,:] = mul(r, sin(theta))
diff --git a/examples/book/chap6/smoothrec b/examples/book/chap6/smoothrec
index 4e14b66..ed96754 100755
--- a/examples/book/chap6/smoothrec
+++ b/examples/book/chap6/smoothrec
@@ -4,14 +4,14 @@
 # Quadratic smoothing.
 
 from math import pi
-from cvxopt import random, blas, lapack 
+from cvxopt import base, blas, lapack 
 from cvxopt.base import matrix, sin, mul
 import pylab
 
 n = 4000
 t = matrix(range(n), tc='d')
 ex = 0.5 * mul( sin(2*pi/n * t), sin(0.01 * t))
-corr = ex + 0.05 * random.normal(n,1)
+corr = ex + 0.05 * base.normal(n,1)
 
 pylab.figure(1, facecolor='w', figsize=(8,5))
 pylab.subplot(211)
diff --git a/examples/book/chap6/tv b/examples/book/chap6/tv
index 8f2a33f..83c6a4b 100755
--- a/examples/book/chap6/tv
+++ b/examples/book/chap6/tv
@@ -4,7 +4,7 @@
 # Total variation reconstruction.
 
 from math import pi
-from cvxopt import random, blas, lapack, solvers
+from cvxopt import base, blas, lapack, solvers
 from cvxopt.base import matrix, spmatrix, sin, mul, div
 solvers.options['show_progress'] = 0
 import pylab
@@ -13,7 +13,7 @@ n = 2000
 t = matrix( range(n), tc='d' )
 ex = matrix( n/4*[1.0] + n/4*[-1.0] + n/4*[1.0] + n/4*[-1.0] ) + \
     0.5 * sin( 2.0*pi/n * t )
-corr = ex + 0.1 * random.normal(n,1)
+corr = ex + 0.1 * base.normal(n,1)
 
 pylab.figure(1, facecolor='w', figsize=(8,5))
 pylab.subplot(211)
@@ -229,7 +229,7 @@ def tv(delta):
 
         return g
 
-    solvers.options['feastol'] = 1e-6
+    solvers.options['feastol'] = 1e-5
     return solvers.cp(F, G, h, kktsolver = Fkkt)['x'][:n]
 
 
diff --git a/examples/book/chap7/chernoff b/examples/book/chap7/chernoff
index 53b8d72..c12ada4 100755
--- a/examples/book/chap7/chernoff
+++ b/examples/book/chap7/chernoff
@@ -5,7 +5,7 @@
 
 import pylab
 from cvxopt.base import matrix, mul, exp
-from cvxopt import solvers, blas, random 
+from cvxopt import solvers, blas, base 
 solvers.options['show_progress'] = False
 
 # Extreme points and inequality description of Voronoi region around 
@@ -89,7 +89,7 @@ if 0:  # uncomment out for the Monte Carlo estimation.
     mcest = []
     ones = matrix(1.0, (1,m))
     for sigma in sigmas: 
-        X = sigma * random.normal(2, N)
+        X = sigma * base.normal(2, N)
         S = b[0][:,N*[0]] - A[0]*X 
         S = ones * (S - abs(S))
         mcest += [ N - len(filter(lambda x: x < 0.0, S)) ]
diff --git a/examples/doc/chap10/l1svc b/examples/doc/chap10/l1svc
index e82ef73..299c3c4 100755
--- a/examples/doc/chap10/l1svc
+++ b/examples/doc/chap10/l1svc
@@ -2,7 +2,7 @@
 
 # The 1-norm support vector classifier of section 9.5.
 
-from cvxopt.random import normal, setseed
+from cvxopt.base import normal, setseed
 from cvxopt.modeling import variable, op, max, sum
 from cvxopt.blas import nrm2
 
diff --git a/examples/doc/chap10/normappr b/examples/doc/chap10/normappr
index ba6c315..8f998be 100755
--- a/examples/doc/chap10/normappr
+++ b/examples/doc/chap10/normappr
@@ -2,7 +2,7 @@
 
 # The norm and penalty approximation problems of section 9.5.
 
-from cvxopt.random import normal, setseed
+from cvxopt.base import normal, setseed
 from cvxopt.modeling import variable, op, max, sum
 
 setseed(0)
diff --git a/examples/doc/chap10/roblp b/examples/doc/chap10/roblp
index 74d8607..614022a 100755
--- a/examples/doc/chap10/roblp
+++ b/examples/doc/chap10/roblp
@@ -2,7 +2,7 @@
 
 # The robust LP example of section 9.5.
 
-from cvxopt.random import normal, uniform  
+from cvxopt.base import normal, uniform  
 from cvxopt.modeling import variable, dot, op, sum  
 from cvxopt.blas import nrm2  
      
diff --git a/examples/doc/chap4/acent b/examples/doc/chap4/acent
index 10df856..839bd85 100755
--- a/examples/doc/chap4/acent
+++ b/examples/doc/chap4/acent
@@ -3,7 +3,7 @@
 # The analytic centering example of section 4.9.
 
 from cvxopt.base import matrix, log, mul, div
-from cvxopt import blas, lapack, random
+from cvxopt import blas, lapack, base
 from math import sqrt
 
 def acent(A,b):
@@ -60,9 +60,9 @@ def acent(A,b):
 # with random mxn Ar and random b1, b2.
 
 m, n  = 500, 500
-Ar = random.normal(m,n);
+Ar = base.normal(m,n);
 A = matrix([Ar, -Ar])
-b = random.uniform(2*m,1)
+b = base.uniform(2*m,1)
 
 x, ntdecrs = acent(A, b)  
 try: 
diff --git a/examples/doc/chap8/l1 b/examples/doc/chap8/l1
index 54c4b89..08932cb 100755
--- a/examples/doc/chap8/l1
+++ b/examples/doc/chap8/l1
@@ -2,7 +2,7 @@
 
 # The 1-norm approximation example of section 8.5.  
 
-from cvxopt import base, random, blas, lapack, solvers
+from cvxopt import base, base, blas, lapack, solvers
 from cvxopt.base import matrix, spdiag, mul, div
 from math import sqrt
 solvers.options['refinement'] = False
@@ -123,7 +123,7 @@ def l1(P, q):
         primalstart={'x': x0, 's': s0}, dualstart={'z': z0})
     return sol['x'][:n],  sol['z'][m:] - sol['z'][:m]    
 
-random.setseed()
+base.setseed()
 m, n = 500, 100
-P, q = random.normal(m,n), random.normal(m,1)
+P, q = base.normal(m,n), base.normal(m,1)
 x, y = l1(P,q)
diff --git a/examples/doc/chap8/mcsdp b/examples/doc/chap8/mcsdp
index 2408946..5051d7c 100755
--- a/examples/doc/chap8/mcsdp
+++ b/examples/doc/chap8/mcsdp
@@ -2,7 +2,7 @@
 
 # The SDP example of section 8.5.
 
-from cvxopt import base, blas, lapack, random, solvers
+from cvxopt import base, blas, lapack, base, solvers
 from cvxopt.base import matrix
 
 def mcsdp(w):
@@ -122,5 +122,5 @@ def mcsdp(w):
     return sol['x'], matrix(sol['z'], (n,n))
 
 n = 100
-w = random.normal(n,n)
+w = base.normal(n,n)
 x, z = mcsdp(w)
diff --git a/examples/doc/chap8/qcl1 b/examples/doc/chap8/qcl1
index d3bf32c..dcbbd75 100755
--- a/examples/doc/chap8/qcl1
+++ b/examples/doc/chap8/qcl1
@@ -2,7 +2,7 @@
 
 # The quadratically constrained 1-norm minimization example of section 8.5.
 
-from cvxopt import random, blas, lapack, solvers
+from cvxopt import base, blas, lapack, solvers
 from cvxopt.base import matrix, mul, div
 from math import sqrt
 
@@ -128,9 +128,9 @@ def qcl1(A, b):
     else:
         return None, None
 
-random.setseed()
+base.setseed()
 m, n = 100, 100
-A, b = random.normal(m,n), random.normal(m,1)
+A, b = base.normal(m,n), base.normal(m,1)
 
 x, z = qcl1(A, b)
 if x is None: print "infeasible"
diff --git a/examples/doc/chap9/acent b/examples/doc/chap9/acent
index c295a25..580c582 100755
--- a/examples/doc/chap9/acent
+++ b/examples/doc/chap9/acent
@@ -2,7 +2,7 @@
 
 # The equality constrained analytical centering example of section 9.1.  
 
-from cvxopt import random, blas
+from cvxopt import base, blas
 from cvxopt.base import matrix, spmatrix, spdiag, log
 from cvxopt import solvers
 
@@ -29,17 +29,17 @@ def acent(A, b):
 # Randomly generate a feasible problem
 
 m, n = 50, 500
-y = random.normal(m,1)
+y = base.normal(m,1)
 
 # Random A with A'*y > 0.
-s = random.uniform(n,1)
-A = random.normal(m,n)
+s = base.uniform(n,1)
+A = base.normal(m,n)
 r = s - A.T * y
 # A = A - (1/y'*y) * y*r'
 blas.ger(y, r, A, alpha = 1.0/blas.dot(y,y)) 
 
 # Random feasible x > 0.
-x = random.uniform(n,1)
+x = base.uniform(n,1)
 b = A*x
 
 x = acent(A,b)
diff --git a/examples/doc/chap9/l1regls b/examples/doc/chap9/l1regls
index 308d3b9..05b2d86 100755
--- a/examples/doc/chap9/l1regls
+++ b/examples/doc/chap9/l1regls
@@ -3,7 +3,7 @@
 # The 1-norm regularized least-squares example of section 9.5.
 
 from cvxopt.base import matrix, spdiag, mul, div
-from cvxopt import base, blas, lapack, solvers, random
+from cvxopt import base, blas, lapack, solvers, base
 import math
 
 def l1regls(A, y):
@@ -149,7 +149,7 @@ def l1regls(A, y):
     return solvers.cp(F, G, h, kktsolver = Fkkt)['x'][:n]
 
 m, n = 100, 1000
-random.setseed()
-A = random.normal(m,n)
-b = random.normal(m)
+base.setseed()
+A = base.normal(m,n)
+b = base.normal(m)
 x = l1regls(A, b)
diff --git a/examples/doc/chap9/robls b/examples/doc/chap9/robls
index 54a80e6..15e9945 100755
--- a/examples/doc/chap9/robls
+++ b/examples/doc/chap9/robls
@@ -3,7 +3,7 @@
 # The robust least-squares example of section 9.1.  
 
 from math import sqrt, ceil, floor
-from cvxopt import random, solvers, blas, lapack
+from cvxopt import base, solvers, blas, lapack
 from cvxopt.base import matrix, spmatrix, spdiag, sqrt, mul, div
 import pylab
 
@@ -25,10 +25,10 @@ def robls(A, b, rho):
     return solvers.cp(F)['x']
 
 
-random.setseed()
+base.setseed()
 m, n  = 500, 100
-A = random.normal(m,n)
-b = random.normal(m,1)
+A = base.normal(m,n)
+b = base.normal(m,1)
 xh = robls(A,b,0.1)
 
 try: import pylab
diff --git a/src/C/amd.c b/src/C/amd.c
index 884290b..5298d8f 100644
--- a/src/C/amd.c
+++ b/src/C/amd.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/base.c b/src/C/base.c
index 02c5e2f..4de92bd 100644
--- a/src/C/base.c
+++ b/src/C/base.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -57,7 +57,6 @@ extern int (*sp_syrk[])(char, char, number, void *, number,
 
 const int  E_SIZE[] = { sizeof(int_t), sizeof(double), sizeof(complex) };
 const char TC_CHAR[][2] = {"i","d","z"} ;
-const char PRINTOPT[][15] = {"iformat","dformat","zformat"} ;
 
 PyObject *base_mod;
 
@@ -1041,24 +1040,6 @@ initbase(void)
   if (PyModule_AddObject(base_mod, "spmatrix", (PyObject *) &spmatrix_tp) < 0)
     return;   
 
-  /* Create the print_options dictionary */
-  PyObject *printopt = PyDict_New();
-  PyObject *dstr = PyString_FromString("5.4e");
-  PyObject *istr = PyString_FromString("5li");
-  PyObject *zstr = PyString_FromString("5.4e");
-  if (PyDict_SetItemString(printopt, "dformat", dstr) ||
-      PyDict_SetItemString(printopt, "iformat", istr) ||
-      PyDict_SetItemString(printopt, "zformat", zstr)) 
-  {
-    Py_XDECREF(printopt); 
-    Py_XDECREF(dstr); Py_XDECREF(istr); Py_XDECREF(zstr);
-    return;
-  }
-  Py_DECREF(dstr); Py_DECREF(istr); Py_DECREF(zstr);
-
-  if (PyModule_AddObject(base_mod, "print_options", printopt) < 0)
-    return;   
-
   One[INT].i = 1; One[DOUBLE].d = 1.0; One[COMPLEX].z = 1.0;
 
   MinusOne[INT].i = -1; MinusOne[DOUBLE].d = -1.0; MinusOne[COMPLEX].z = -1.0;
diff --git a/src/C/blas.c b/src/C/blas.c
index 3e7af0c..31ce43a 100644
--- a/src/C/blas.c
+++ b/src/C/blas.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/cholmod.c b/src/C/cholmod.c
index 46e6dc1..b2a2e39 100644
--- a/src/C/cholmod.c
+++ b/src/C/cholmod.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/cvxopt.h b/src/C/cvxopt.h
index 60c5d31..d5748c2 100644
--- a/src/C/cvxopt.h
+++ b/src/C/cvxopt.h
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/dense.c b/src/C/dense.c
index b171b30..f5147cd 100644
--- a/src/C/dense.c
+++ b/src/C/dense.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -57,17 +57,11 @@ int get_id(void *, int ) ;
 
 extern const int  E_SIZE[];
 extern const char TC_CHAR[][2];
-extern const char PRINTOPT[][15];
 extern number One[3], MinusOne[3], Zero[3];
 
+extern PyObject *base_mod;
 
 extern PyTypeObject spmatrix_tp ;
-/*
-spmatrix * SpMatrix_New(int_t, int_t, int, int ) ;
-spmatrix * SpMatrix_NewFromSpMatrix(spmatrix *, int, int) ; 
-spmatrix * SpMatrix_NewFromIJV(matrix *, matrix *, matrix *, 
-    int_t, int_t, int, int) ;
-*/
 
 PyTypeObject matrix_tp ;
 matrix * Matrix_NewFromNumber(int , int , int , void *, int ) ;
@@ -307,7 +301,7 @@ matrix * Matrix_NewFromSequence(PyObject *x, int id)
     }    
   }
 
-  if (!len) return Matrix_New(0, 0, (id < 0 ? INT : id));
+  if (!len) return Matrix_New(0, 1, (id < 0 ? INT : id));
 
   matrix *L = Matrix_New(len,1,id);
   if (!L) { Py_DECREF(seq); return (matrix *)PyErr_NoMemory(); }
@@ -461,7 +455,7 @@ matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
   int nrows=0, ncols=0;
   char tc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oc:matrix", kwlist, 
+  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOc:matrix", kwlist, 
 	  &Objx, &size, &tc))
     return NULL;
 
@@ -474,6 +468,8 @@ matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
   if (tc && !(VALID_TC_MAT(tc))) PY_ERR_TYPE("tc must be 'i', 'd' or 'z'");  
   int id = (tc ? TC2ID(tc) : -1);
 
+  if (!Objx) return (PyObject *)Matrix_New(0, 0, (id == -1 ? INT : id));
+
   matrix *ret = NULL;
   /* x is a number */
   if (PY_NUMBER(Objx)) 
@@ -528,87 +524,35 @@ matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 }
 
 static PyObject *
-matrix_str(matrix *self)
-{  
-  PyObject *printopt;
-
-  /* these PyObject variables will all be borrowed references */
-  PyObject *opt, *s, *stmp=NULL;
-
-  if (self->nrows == 0 || self->ncols == 0)
-    return Py_BuildValue("s","");
-  
-  if (!(printopt = PyObject_GetAttrString(base_mod, "print_options")) ||
-      !PyDict_Check(printopt)) {
-    PY_ERR(PyExc_AttributeError, "cannot access 'print_options' dictionary");
-  }
- 
-  if (!(opt = PyDict_GetItemString(printopt, PRINTOPT[self->id]))) {
-    Py_DECREF(printopt);
-    PY_ERR(PyExc_KeyError, "missing print format key in 'base_options'");
-  }
+matrix_str(matrix *self) {
 
-  char tmp[50], format[20] = "%- ", format_im[20] = "%";
-  strncat(format, PyString_AsString(opt), 18);
-  if (MAT_ID(self)==COMPLEX)
-    strncat(format_im, PyString_AsString(opt), 18);
+  PyObject *str, *ret;
+   
+  if (!(str = PyObject_GetAttrString(base_mod, "matrix_str")))
+    PY_ERR(PyExc_KeyError, "missing 'matrix_str' in 'base_options'");
 
-  if (!(s = PyString_FromString(""))) {
-    Py_DECREF(printopt);
-    return PyErr_NoMemory();
-  }
+  if (!PyCallable_Check(str)) PY_ERR_TYPE("'matrix_str' is not callable");
 
-  int i, j;
-  for (i=0; i<self->nrows; i++) {
+  ret = PyObject_CallFunctionObjArgs(str, (PyObject *)self, NULL);
+  Py_DECREF(str);
 
-    for (j=0; j<self->ncols; j++) {
-      PyString_ConcatAndDel(&s, PyString_FromString("  "));
-      switch (MAT_ID(self)) {
-      case DOUBLE: 
-	if ((snprintf(tmp,50,format, MAT_BUFD(self)[j*self->nrows+i])<0) ||
-	    !(stmp = PyString_FromString(tmp)))
-	  goto fail;
-	break;
-      case INT: 
-	if ((snprintf(tmp,50,format,MAT_BUFI(self)[j*self->nrows+i])<0) ||
-	    !(stmp = PyString_FromString(tmp)))
-	  goto fail;
-	break;
-      case COMPLEX:
-	if ((snprintf(tmp,50,format,
-		    creal(MAT_BUFZ(self)[j*self->nrows+i]))<0) ||
-	    !(stmp = PyString_FromString(tmp)))
-	  goto fail;
-	
-	if (snprintf(tmp,50,format_im, 
-		fabs(cimag(MAT_BUFZ(self)[j*self->nrows+i])))<0)
-	  goto fail;
-	
-	PyString_ConcatAndDel(&stmp, cimag(MAT_BUFZ(self)[j*self->nrows+i])>0 ?
-	    PyString_FromString("+j") : PyString_FromString("-j"));
-	PyString_ConcatAndDel(&stmp, PyString_FromString(tmp));       
-	break;
-      }   
-      PyString_ConcatAndDel(&s, stmp);
-    }
-    PyString_ConcatAndDel(&s, PyString_FromString("\n"));
-  }
-  
-  Py_DECREF(printopt);
-  return s;
-   
- fail:
-  Py_DECREF(printopt); 
-  Py_DECREF(s); return PyErr_NoMemory();
+  return ret;  
 }
 
 static PyObject *
 matrix_repr(matrix *self) {
 
-  PyObject *s = PyString_FromFormat("<%ldx%ld matrix, tc='%s'>",
-      (long)self->nrows,(long)self->ncols,TC_CHAR[self->id]);
+  PyObject *repr, *ret;
+   
+  if (!(repr = PyObject_GetAttrString(base_mod, "matrix_repr")))
+    PY_ERR(PyExc_KeyError, "missing 'matrix_repr' in 'base_options'");
+
+  if (!PyCallable_Check(repr)) PY_ERR_TYPE("'matrix_repr' is not callable");
+
+  ret = PyObject_CallFunctionObjArgs(repr, (PyObject *)self, NULL);
+  Py_DECREF(repr);
 
-  return s;
+  return ret;
 }
 
 /*
diff --git a/src/C/dsdp.c b/src/C/dsdp.c
index d55cb22..72c2de4 100644
--- a/src/C/dsdp.c
+++ b/src/C/dsdp.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/fftw.c b/src/C/fftw.c
index bc40eaa..3d89b1a 100644
--- a/src/C/fftw.c
+++ b/src/C/fftw.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/glpk.c b/src/C/glpk.c
index ccc9d3b..9226175 100644
--- a/src/C/glpk.c
+++ b/src/C/glpk.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/random.c b/src/C/gsl.c
similarity index 95%
rename from src/C/random.c
rename to src/C/gsl.c
index aac8c69..ca779a0 100644
--- a/src/C/random.c
+++ b/src/C/gsl.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@
 
 #include <time.h>
 
-PyDoc_STRVAR(random__doc__,"Random Module.");
+PyDoc_STRVAR(gsl__doc__,"Random Module.");
 
 static unsigned long seed = 0;
 static const gsl_rng_type *rng_type;
@@ -162,7 +162,7 @@ uniform(PyObject *self, PyObject *args, PyObject *kwrds)
   return (PyObject *)obj;
 }
 
-static PyMethodDef random_functions[] = {
+static PyMethodDef gsl_functions[] = {
   {"getseed", (PyCFunction)getseed, METH_VARARGS|METH_KEYWORDS, doc_getseed},  
   {"setseed", (PyCFunction)setseed, METH_VARARGS|METH_KEYWORDS, doc_setseed},  
   {"normal", (PyCFunction)normal, METH_VARARGS|METH_KEYWORDS, doc_normal},  
@@ -171,11 +171,11 @@ static PyMethodDef random_functions[] = {
 };
 
 PyMODINIT_FUNC
-initrandom(void)
+initgsl(void)
 {
   PyObject *m;
 
-  m = Py_InitModule3("cvxopt.random", random_functions, random__doc__);
+  m = Py_InitModule3("cvxopt.gsl", gsl_functions, gsl__doc__);
   
   if (import_cvxopt() < 0)
     return;
diff --git a/src/C/lapack.c b/src/C/lapack.c
index 7852ab1..09ead80 100644
--- a/src/C/lapack.c
+++ b/src/C/lapack.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/misc.h b/src/C/misc.h
index a70763f..e8c5477 100644
--- a/src/C/misc.h
+++ b/src/C/misc.h
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/C/sparse.c b/src/C/sparse.c
index 71b9f7d..22ea582 100644
--- a/src/C/sparse.c
+++ b/src/C/sparse.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,6 @@ extern PyObject *base_mod;
 
 extern const int  E_SIZE[];
 extern const char TC_CHAR[][2];
-extern const char PRINTOPT[][15];
 extern number One[3], MinusOne[3], Zero[3];
 
 extern void (*write_num[])(void *, int, void *, int) ;
@@ -2446,82 +2445,37 @@ spmatrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 } 
 
 static PyObject *
-spmatrix_str(spmatrix *self)
-{    
-  char s[50] = "(%li, %li) %- ";
-  
-  /* these PyObject variables will all be borrowed references */
-  PyObject *printopt, *opt;
-  
-  if (!(printopt = PyObject_GetAttrString(base_mod, "print_options")) ||
-      !PyDict_Check(printopt)) {
-    PY_ERR(PyExc_AttributeError, "cannot access 'print_options' dictionary");
-  }
-  
-  if (!(opt = PyDict_GetItemString(printopt, PRINTOPT[SP_ID(self)]))) {
-    Py_DECREF(printopt);
-    PY_ERR(PyExc_KeyError, "missing print format key in 'base_options'");
-  }
+spmatrix_str(matrix *self) {
 
-  char tmp[50], format_im[20] = "%";
-  if (SP_ID(self)==COMPLEX)
-    strncat(format_im, PyString_AsString(opt), 18);
+  PyObject *str, *ret;
+   
+  if (!(str = PyObject_GetAttrString(base_mod, "spmatrix_str")))
+    PY_ERR(PyExc_KeyError, "missing 'spmatrix_str' in 'base_options'");
 
-  strncat(s, PyString_AsString(opt), 37);
+  if (!PyCallable_Check(str)) PY_ERR_TYPE("'spmatrix_str' is not callable");
 
-  PyObject *ret = PyString_FromFormat("SIZE: (%ld,%ld)\n",
-      (long)SP_NROWS(self),(long)SP_NCOLS(self));
+  ret = PyObject_CallFunctionObjArgs(str, (PyObject *)self, NULL);
+  Py_DECREF(str);
 
-  int_t j, k;
-  for (k=0; k<SP_NCOLS(self); k++)
-    for (j=SP_COL(self)[k]; j<SP_COL(self)[k+1]; j++) {
-
-      char t[100];
-      switch (SP_ID(self)) {
-      case DOUBLE: 
-	if (snprintf(t,100,s,SP_ROW(self)[j],k,SP_VALD(self)[j])<0) 
-	  goto fail;
-	break;
-      case COMPLEX:
-
-	if (snprintf(t,100,s,SP_ROW(self)[j],k,creal(SP_VALZ(self)[j]))<0)
-	  goto fail;
-	
-	if (strncat(t,(cimag(SP_VALZ(self)[j])>0 ? "+j" : "-j"),100)<0)
-	  goto fail;
+  return ret;  
+}
 
-	if (snprintf(tmp,100,format_im,fabs(cimag(SP_VALZ(self)[j])))<0)
-	  goto fail;
+static PyObject *
+spmatrix_repr(matrix *self) {
 
-	if (strncat(t,tmp,100)<0)
-	  goto fail;
-	
-	break;
-      }   
-      
-      PyString_ConcatAndDel(&ret, PyString_FromFormat("%s\n",t));
-    }  
-    
-  Py_DECREF(printopt);
-  return ret;
+  PyObject *repr, *ret;
    
- fail:
-  Py_DECREF(printopt); 
-  Py_DECREF(ret); return PyErr_NoMemory();
+  if (!(repr = PyObject_GetAttrString(base_mod, "spmatrix_repr")))
+    PY_ERR(PyExc_KeyError, "missing 'spmatrix_repr' in 'base_options'");
 
-} 
+  if (!PyCallable_Check(repr)) PY_ERR_TYPE("'spmatrix_repr' is not callable");
 
-static PyObject *
-spmatrix_repr(spmatrix *self) {
-  
-  PyObject *s = PyString_FromFormat("<%ldx%ld spmatrix, tc='%s', nnz=%ld>",
-      (long)SP_NROWS(self), (long)SP_NCOLS(self),
-      TC_CHAR[SP_ID(self)], (long)SP_NNZ(self));
+  ret = PyObject_CallFunctionObjArgs(repr, (PyObject *)self, NULL);
+  Py_DECREF(repr);
 
-  return s;
+  return ret;
 }
 
-
 static PyObject * spmatrix_get_size(spmatrix *self, void *closure)
 {
   PyObject *t = PyTuple_New(2);
@@ -4014,7 +3968,7 @@ PyTypeObject spmatrix_tp = {
 	&spmatrix_as_mapping,                   /* tp_as_mapping */
 	0,					/* tp_hash */
 	0,					/* tp_call */
-	(reprfunc)spmatrix_str,			/* tp_str */
+	(reprfunc)spmatrix_str, 		/* tp_str */
 	0,					/* tp_getattro */
 	0,			                /* tp_setattro */
 	0,			                /* tp_as_buffer */
diff --git a/src/C/umfpack.c b/src/C/umfpack.c
index 2e8af4a..5708fa4 100644
--- a/src/C/umfpack.c
+++ b/src/C/umfpack.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2004-2007 J. Dahl and L. Vandenberghe.
  *
- * This file is part of CVXOPT version 0.9.1.
+ * This file is part of CVXOPT version 0.9.2.
  *
  * CVXOPT is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/src/python/__init__.py b/src/python/__init__.py
index 46ca8ae..4db19f6 100644
--- a/src/python/__init__.py
+++ b/src/python/__init__.py
@@ -1,2 +1,101 @@
-__all__ = ['base', 'random', 'blas', 'lapack', 'amd', 'umfpack', 'cholmod',
-    'solvers', 'modeling', 'info', 'mosek']
+__all__ = ['base', 'blas', 'lapack', 'amd', 'umfpack', 'cholmod', 'solvers',
+    'modeling', 'printing', 'info']
+
+
+import base, printing
+base.matrix_str    = printing.matrix_str_default
+base.matrix_repr   = printing.matrix_repr_default
+base.spmatrix_str  = printing.spmatrix_str_default
+base.spmatrix_repr = printing.spmatrix_repr_default
+
+def normal(nrows, ncols=1, mean=0.0, std=1.0):
+    '''Randomly generates a matrix with normally distributed entries.
+
+    normal(nrows, ncols=1, mean=0, std=1)
+  
+    PURPOSE
+    Returns a matrix with typecode 'd' and size nrows by ncols, with
+    its entries randomly generated from a normal distribution with mean
+    m and standard deviation std.
+
+    ARGUMENTS
+    nrows     number of rows
+
+    ncols     number of columns
+
+    mean      approximate mean of the distribution
+    std       standard deviation of the distribution'''
+
+    try:    
+        from cvxopt import gsl
+    except:
+        from cvxopt.base import matrix
+        from random import gauss
+        return matrix([gauss(mean, std) for k in xrange(nrows*ncols)],
+                      (nrows,ncols) )
+        
+    return gsl.normal(nrows, ncols, mean, std)
+
+def uniform(nrows, ncols=1, a=0, b=1):
+    '''Randomly generates a matrix with uniformly distributed entries.
+    
+    uniform(nrows, ncols=1, a=0, b=1)
+
+    PURPOSE
+    Returns a matrix with typecode 'd' and size nrows by ncols, with
+    its entries randomly generated from a uniform distribution on the
+    interval (a,b).
+
+    ARGUMENTS
+    nrows     number of rows
+
+    ncols     number of columns
+
+    a         lower bound
+
+    b         upper bound'''
+
+    try:    
+        from cvxopt import gsl
+    except:
+        from cvxopt.base import matrix
+        from random import uniform
+        return matrix([uniform(a, b) for k in xrange(nrows*ncols)],
+                      (nrows,ncols) )
+
+    return gsl.uniform(nrows, ncols, a, b)
+
+def setseed(val = 0):
+    '''Sets the seed value for the random number generator.
+
+    setseed(val = 0)
+    
+    ARGUMENTS
+    value     integer seed.  If the value is 0, the current system time  
+              is used. '''    
+
+    try:    
+        from cvxopt import gsl
+        gsl.setseed(val)
+    except:
+        from random import seed
+        if val is 0: val = None
+        seed(val)
+        
+ 
+def getseed():
+    '''Returns the seed value for the random number generator.
+    
+    getseed()'''
+
+    try:    
+        from cvxopt import gsl
+        return gsl.getseed()
+    except:
+        raise NotImplementedError, "getseed() not installed (requires GSL) "
+    
+
+base.normal = normal
+base.uniform = uniform
+base.setseed = setseed
+base.getseed = getseed
diff --git a/src/python/coneprog.py b/src/python/coneprog.py
index 8c416e1..7e20119 100644
--- a/src/python/coneprog.py
+++ b/src/python/coneprog.py
@@ -4,7 +4,7 @@ Solver for linear, second-order cone and semidefinite programming.
 
 # Copyright 2004-2007 J. Dahl and L. Vandenberghe.
 # 
-# This file is part of CVXOPT version 0.9.1.
+# This file is part of CVXOPT version 0.9.2.
 #
 # CVXOPT is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/python/cvxprog.py b/src/python/cvxprog.py
index 6ba8cb0..758117f 100644
--- a/src/python/cvxprog.py
+++ b/src/python/cvxprog.py
@@ -8,7 +8,7 @@ to the quadratic programming solver from MOSEK.
 
 # Copyright 2004-2007 J. Dahl and L. Vandenberghe.
 # 
-# This file is part of CVXOPT version 0.9.1.
+# This file is part of CVXOPT version 0.9.2.
 #
 # CVXOPT is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/python/info.py b/src/python/info.py
index f45bb11..15844c6 100644
--- a/src/python/info.py
+++ b/src/python/info.py
@@ -1,8 +1,8 @@
-version = '0.9.1'
+version = '0.9.2'
 
 def license(): print(
 """
-CVXOPT version 0.9.1.  Copyright (c) 2004-2007 J. Dahl and L. Vandenberghe.
+CVXOPT version 0.9.2.  Copyright (c) 2004-2007 J. Dahl and L. Vandenberghe.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/src/python/misc.py b/src/python/misc.py
index cb553f2..bc129a4 100644
--- a/src/python/misc.py
+++ b/src/python/misc.py
@@ -1,6 +1,6 @@
 # Copyright 2004-2007 J. Dahl and L. Vandenberghe.
 # 
-# This file is part of CVXOPT version 0.9.1.
+# This file is part of CVXOPT version 0.9.2.
 #
 # CVXOPT is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/python/modeling.py b/src/python/modeling.py
index 0d9208b..9ebb80e 100644
--- a/src/python/modeling.py
+++ b/src/python/modeling.py
@@ -7,7 +7,7 @@ piecewise-linear objective and constraint functions.
 
 # Copyright 2004-2007 J. Dahl and L. Vandenberghe.
 # 
-# This file is part of CVXOPT version 0.9.1.
+# This file is part of CVXOPT version 0.9.2.
 #
 # CVXOPT is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/python/mosek.py b/src/python/mosek.py
index 93a3e6e..90b88d4 100644
--- a/src/python/mosek.py
+++ b/src/python/mosek.py
@@ -4,7 +4,7 @@ CVXOPT interface for MOSEK 5.0
 
 # Copyright 2004-2007 J. Dahl and L. Vandenberghe.
 # 
-# This file is part of CVXOPT version 0.9.1
+# This file is part of CVXOPT version 0.9.2.
 #
 # CVXOPT is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/python/printing.py b/src/python/printing.py
new file mode 100644
index 0000000..56c39dc
--- /dev/null
+++ b/src/python/printing.py
@@ -0,0 +1,196 @@
+
+# Copyright 2004-2007 J. Dahl and L. Vandenberghe.
+# 
+# This file is part of CVXOPT version 0.9.2.
+#
+# CVXOPT is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# CVXOPT is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+options = {'dformat' : '% .2e',
+           'iformat' : '% i',
+           'width' : 7,
+           'height' : -1}
+
+def matrix_str_default(X):
+
+    from sys import maxint
+    from string import rjust, center
+    from printing import options
+
+    width, height = options['width'], options['height']
+    iformat, dformat = options['iformat'], options['dformat']
+
+    sgn = ['-','+']
+
+    if   X.typecode is 'i': fmt = iformat
+    else: fmt = dformat
+
+    s = ""
+    m, n   = X.size
+    if width < 0: width = maxint
+    if height < 0: height = maxint
+
+    if width*height is 0: return ""
+    if len(X) is 0: return ""
+ 
+    rlist = range(0,min(m,height))
+    clist = range(0,min(n,width))
+
+    if X.typecode is 'z':
+        twidth = max([ len(fmt % X[i,j].real + sgn[X[i,j].imag>0] + 'j' + \
+                              (fmt % abs(X[i,j].imag)).lstrip() ) \
+                          for i in rlist for j in clist ])
+    else:
+        twidth = max([ len(fmt % X[i,j]) for i in rlist for j in clist ])
+
+    for i in rlist:
+        s += '['
+
+        for j in clist:
+
+            if X.typecode is 'z':
+                s += rjust(fmt % X[i,j].real + sgn[X[i,j].imag>0] + 'j' + \
+                               (fmt % abs(X[i,j].imag)).lstrip(),twidth) 
+            else:
+                s += rjust(fmt % X[i,j],twidth)
+
+            s += ' '
+        
+        if width < n: s += '... ]\n'        
+        else: s = s[:-1] + ']\n'
+           
+    if height < m: 
+        s += "[" + min(n,width)*(center(':',twidth)+' ')
+
+        if width < n: s += '   ]\n'
+        else: s = s[:-1] + ']\n'
+
+    return s
+
+def matrix_repr_default(X):
+    return "<%ix%i matrix, tc='%c'>" %(X.size[0],X.size[1],X.typecode)
+
+def spmatrix_str_default(X):
+
+    from sys import maxint
+    from string import rjust, center
+    from printing import options
+
+    width, height = options['width'], options['height']
+    iformat, dformat = options['iformat'], options['dformat']
+
+    sgn = ['-','+']
+
+    if   X.typecode is 'i': fmt = iformat
+    else: fmt = dformat
+
+    s = ""
+    m, n   = X.size
+    if width < 0: width = maxint
+    if height < 0: height = maxint
+
+    if width*height is 0: return ""
+    if len(X) is 0: return ""
+ 
+    rlist = range(0,min(m,height))
+    clist = range(0,min(n,width))
+
+    Xr = X[:min(m,height),:min(n,width)]
+    Idx = zip(*(Xr.I,Xr.J))
+    Zero = '0'
+    
+    if len(Idx) > 0:
+        if X.typecode is 'z':
+            twidth = max([ len(fmt % X[i,j].real + sgn[X[i,j].imag>0] + 'j' + \
+                                  (fmt % abs(X[i,j].imag)).lstrip() ) \
+                              for i in rlist for j in clist ])
+        else:
+            twidth = max([ len(fmt % X[i,j]) for i in rlist for j in clist ])
+    else:
+        twidth = len(Zero)
+
+    for i in rlist:
+        s += '['
+
+        for j in clist:
+
+            if (i,j) in Idx:
+                if X.typecode is 'z':
+                    s += rjust(fmt % X[i,j].real + sgn[X[i,j].imag>0] + 'j' + \
+                                   (fmt % abs(X[i,j].imag)).lstrip(),twidth)
+                else:
+                    s += rjust(fmt % X[i,j],twidth)
+            else: 
+                s += center(Zero, twidth)
+                
+            s += ' '
+        
+        if width < n: s += '... ]\n'        
+        else: s = s[:-1] + "]\n"
+           
+    if height < m: 
+        s += "[" + min(n,width)*(center(':',twidth)+' ')
+
+        if width < n: s += '   ]\n'
+        else: s = s[:-1] + ']\n'
+
+    return s
+
+
+def spmatrix_str_triplet(X):
+
+    from string import rjust
+    from printing import options
+
+    iformat, dformat = options['iformat'], options['dformat']
+
+    sgn = ['-','+']
+
+    if   X.typecode is 'i': fmt = iformat
+    else: fmt = dformat
+
+    s = ""
+    #s = "<%ix%i sparse matrix with %i non-zeros>\n" %(m, n, len(X))
+    
+    if len(X) > 0:
+        if X.typecode is 'z':
+            twidth = max([ len(fmt % Xk.real + sgn[Xk.imag>0] + 'j' + \
+                                   (fmt % abs(Xk.imag)).lstrip() ) \
+                               for Xk in X.V ])
+        else:
+            twidth = max([ len(fmt % Xk) for Xk in X.V ])
+
+        imax = max([ len(str(i)) for i in X.I ])
+        jmax = max([ len(str(j)) for j in X.J ])
+
+    else:
+        twidth = 0 
+
+    for k in xrange(len(X)):
+        s += "(" 
+        s += rjust(str(X.I[k]),imax) + "," + rjust(str(X.J[k]),jmax) 
+        s += ") "
+
+        if X.typecode is 'z':
+            s += rjust(fmt % X.V[k].real + sgn[X.V[k].imag>0] + 'j' + \
+                           (fmt % abs(X.V[k].imag)).lstrip(),twidth)
+        else:
+            s += rjust(fmt % X.V[k],twidth)
+        
+        s += "\n"
+                
+    return s
+
+def spmatrix_repr_default(X):
+    return "<%ix%i matrix, tc='%c', nnz=%i>" \
+        %(X.size[0],X.size[1],X.typecode,len(X.V))
diff --git a/src/python/solvers.py b/src/python/solvers.py
index 712619d..add37c4 100644
--- a/src/python/solvers.py
+++ b/src/python/solvers.py
@@ -14,7 +14,7 @@ options:  dictionary with customizable algorithm parameters.
 
 # Copyright 2004-2007 J. Dahl and L. Vandenberghe.
 # 
-# This file is part of CVXOPT version 0.9.1.
+# This file is part of CVXOPT version 0.9.2.
 #
 # CVXOPT is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/src/setup.py b/src/setup.py
index b180578..92fdb4a 100644
--- a/src/setup.py
+++ b/src/setup.py
@@ -4,40 +4,41 @@ from os import listdir
 # directory containing libblas and liblapack
 ATLAS_LIB_DIR = '/usr/lib'
 
-# Set to 1 if you are installing the GSL random number generator module.
+# Set to 1 if you are using the random number generators in the GNU
+# Scientific Library.
 BUILD_GSL = 0
 
-# directory containing libgsl (used only when BUILD_GSL = 1)
+# Directory containing libgsl (used only when BUILD_GSL = 1).
 GSL_LIB_DIR = '/usr/lib'       
 
-# directory containing the GSL header files (used only when BUILD_GSL = 1)
+# Directory containing the GSL header files (used only when BUILD_GSL = 1).
 GSL_INC_DIR = '/usr/include/gsl'  
 
 # Set to 1 if you are installing the fftw module.
 BUILD_FFTW = 0
 
-# directory containing libfftw3 (used only when BUILD_FFTW = 1)
+# Directory containing libfftw3 (used only when BUILD_FFTW = 1).
 FFTW_LIB_DIR = '/usr/lib'       
 
-# directory containing fftw.h (used only when BUILD_FFTW = 1)
+# Directory containing fftw.h (used only when BUILD_FFTW = 1).
 FFTW_INC_DIR = '/usr/include'  
 
 # Set to 1 if you are installing the glpk module.
 BUILD_GLPK = 0
 
-# directory containing libglpk (used only when BUILD_GLPK = 1)
+# Directory containing libglpk (used only when BUILD_GLPK = 1).
 GLPK_LIB_DIR = '/usr/lib'       
 
-# directory containing glpk.h (used only when BUILD_GLPK = 1)
+# Directory containing glpk.h (used only when BUILD_GLPK = 1).
 GLPK_INC_DIR = '/usr/include'  
 
 # Set to 1 if you are installing the DSDP module.
 BUILD_DSDP = 0
 
-# directory containing libdsdp (used only when BUILD_DSDP = 1)
+# Directory containing libdsdp (used only when BUILD_DSDP = 1).
 DSDP_LIB_DIR = '/usr/lib'
  
-# directory containing dsdp5.h (used only when BUILD_DSDP = 1)
+# Directory containing dsdp5.h (used only when BUILD_DSDP = 1).
 DSDP_INC_DIR = '/usr/include'
 
 
@@ -46,11 +47,11 @@ extmods = []
 # optional modules
 
 if BUILD_GSL:
-    random = Extension('random', libraries = ['m', 'gsl', 'blas'],
+    gsl = Extension('gsl', libraries = ['m', 'gsl', 'blas'],
         include_dirs = [ GSL_INC_DIR ],
         library_dirs = [ GSL_LIB_DIR ],
-        sources = ['C/random.c'] )
-    extmods += [random];
+        sources = ['C/gsl.c'] )
+    extmods += [gsl];
 
 if BUILD_FFTW:
     fftw = Extension('fftw', libraries = ['fftw3', 'blas'],
@@ -151,7 +152,7 @@ extmods += [base, blas, lapack, umfpack, cholmod, amd]
 
 setup (name = 'cvxopt', 
     description = 'Convex optimization package',
-    version = '0.9.1', 
+    version = '0.9.2', 
     long_description = '''
 CVXOPT is a free software package for convex optimization based on the 
 Python programming language. It can be used with the interactive Python 
@@ -161,10 +162,10 @@ purpose is to make the development of software for convex optimization
 applications straightforward by building on Python's extensive standard 
 library and on the strengths of Python as a high-level programming 
 language.''', 
-    author='J. Dahl and L. Vandenberghe',
-    author_email='joachim at es.aau.dk, vandenbe at ee.ucla.edu',
-    url='http://abel.ee.ucla.edu/cvxopt',
-    license='GNU GPL version 3',
+    author = 'J. Dahl and L. Vandenberghe',
+    author_email = 'joachim at es.aau.dk, vandenbe at ee.ucla.edu',
+    url = 'http://abel.ee.ucla.edu/cvxopt',
+    license = 'GNU GPL version 3',
     ext_package = "cvxopt",
     ext_modules = extmods,
     package_dir = {"cvxopt": "python"},

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cvxopt.git



More information about the debian-science-commits mailing list