2.9 Printing Options

The format used for printing dense matrices (and the sparse matrices discussed in chapter 6) is controlled by the dictionary cvxopt.base.print_options. The dictionary has three keys, 'iformat', 'dformat', 'zformat' that control, respectively, how integer, double and complex numbers are printed. The fields are C printf format strings with default values '5.4e' for 'd' and 'z' matrices and '5i' for 'i' matrices.
>>> 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