Navigation

Operators and Keywords

Function List:

C++ API

pr-output.cc File Reference

#include <cfloat>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include "Array-util.h"
#include "CMatrix.h"
#include "Range.h"
#include "cmd-edit.h"
#include "dMatrix.h"
#include "lo-mappers.h"
#include "lo-math.h"
#include "mach-info.h"
#include "oct-cmplx.h"
#include "quit.h"
#include "str-vec.h"
#include "Cell.h"
#include "defun.h"
#include "error.h"
#include "gripes.h"
#include "oct-obj.h"
#include "oct-stream.h"
#include "pager.h"
#include "pr-output.h"
#include "sysdep.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"

Include dependency graph for pr-output.cc:


Classes

class  float_format
class  pr_formatted_float
class  pr_rational_float
union  equiv
class  octave_print_conv< T >

Defines

#define PRINT_CHAR_BITS(os, c)
#define PRINT_CHAR_BITS_SWAPPED(os, c)
#define PRINT_ND_ARRAY(os, nda, NDA_T, ELT_T, MAT_T)
#define PRINT_CONV(T1, T2)
#define INSTANTIATE_ABS(T)   template /* static */ inline T abs (T)
#define SPECIALIZE_UABS(T)
#define PRINT_INT_SCALAR_INTERNAL(TYPE)
#define PRINT_INT_ARRAY_INTERNAL(TYPE)

Functions

std::ostreamoperator<< (std::ostream &os, const pr_formatted_float &pff)
std::ostreamoperator<< (std::ostream &os, const pr_rational_float &prf)
template<class T >
void pr_plus_format (std::ostream &os, const T &val)
void octave_print_internal (std::ostream &os, double d, bool)
void octave_print_internal (std::ostream &os, const Matrix &m, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const DiagMatrix &m, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const NDArray &nda, bool pr_as_read_syntax, int extra_indent)
template<>
void pr_plus_format (std::ostream &os, const Complex &c)
void octave_print_internal (std::ostream &os, const Complex &c, bool)
void octave_print_internal (std::ostream &os, const ComplexMatrix &cm, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const ComplexDiagMatrix &cm, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const PermMatrix &m, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const ComplexNDArray &nda, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, bool d, bool pr_as_read_syntax)
void octave_print_internal (std::ostream &os, float d, bool pr_as_read_syntax)
void octave_print_internal (std::ostream &os, const FloatMatrix &m, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const FloatDiagMatrix &m, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const FloatNDArray &nda, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const FloatComplex &c, bool pr_as_read_syntax)
void octave_print_internal (std::ostream &os, const FloatComplexMatrix &cm, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const FloatComplexDiagMatrix &cm, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const FloatComplexNDArray &nda, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const Range &r, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const boolMatrix &bm, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const boolNDArray &nda, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const charMatrix &chm, bool pr_as_read_syntax, int, bool pr_as_string)
void octave_print_internal (std::ostream &os, const charNDArray &nda, bool pr_as_read_syntax, int extra_indent, bool pr_as_string)
void octave_print_internal (std::ostream &os, const std::string &s, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &os, const Array< std::string > &nda, bool pr_as_read_syntax, int)
 PRINT_CONV (octave_int8, octave_int16)
template<class T >
void pr_int (std::ostream &os, const T &d, int fw=0)
template<class T >
T abs (T x)
 INSTANTIATE_ABS (signed char)
 INSTANTIATE_ABS (short)
 INSTANTIATE_ABS (int)
 INSTANTIATE_ABS (long)
template void pr_int (std::ostream &, const octave_int8 &, int)
template<class T >
void octave_print_internal_template (std::ostream &os, const octave_int< T > &val, bool)
template<class T >
void octave_print_internal_template (std::ostream &os, const intNDArray< T > &nda, bool pr_as_read_syntax, int extra_indent)
void octave_print_internal (std::ostream &, const Cell &, bool, int, bool)
 DEFUN (rats, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} rats (@var{x}, @var{len})\n\ Convert @var{x} into a rational approximation represented as a string.\n\ You can convert the string back into a matrix as follows:\n\ \n\ @example\n\ @group\n\ r = rats(hilb(4));\n\ x = str2num(r)\n\ @end group\n\ @end example\n\ \n\ The optional second argument defines the maximum length of the string\n\ representing the elements of @var{x}. By default @var{len} is 9.\n\ @seealso{format, rat}\n\ @end deftypefn")
 DEFUN (disp, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} disp (@var{x})\n\ Display the value of @var{x}. For example,\n\ \n\ @example\n\ @group\n\ disp (\"The value of pi is:\"), disp (pi)\n\ \n\ @print{} the value of pi is:\n\ @print{} 3.1416\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ Note that the output from @code{disp} always ends with a newline.\n\ \n\ If an output value is requested, @code{disp} prints nothing and\n\ returns the formatted output in a string.\n\ @seealso{fdisp}\n\ @end deftypefn")
 DEFUN (fdisp, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fdisp (@var{fid}, @var{x})\n\ Display the value of @var{x} on the stream @var{fid}. For example,\n\ \n\ @example\n\ @group\n\ fdisp (stdout, \"The value of pi is:\"), fdisp (stdout, pi)\n\ \n\ @print{} the value of pi is:\n\ @print{} 3.1416\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ Note that the output from @code{fdisp} always ends with a newline.\n\ @seealso{disp}\n\ @end deftypefn")
 DEFUN (format, args,,"-*- texinfo -*-\n\ @deffn {Command} format\n\ @deffnx {Command} format options\n\ Reset or specify the format of the output produced by @code{disp} and\n\ Octave's normal echoing mechanism. This command only affects the display\n\ of numbers but not how they are stored or computed. To change the internal\n\ representation from the default double use one of the conversion functions\n\ such as @code{single}, @code{uint8}, @code{int64}, etc.\n\ \n\ By default, Octave displays 5 significant digits in a human readable form\n\ (option @samp{short} paired with @samp{loose} format for matrices).\n\ If @code{format} is invoked without any options, this default format\n\ is restored.\n\ \n\ Valid formats for floating point numbers are listed in the following\n\ table.\n\ \n\ @table @code\n\ @item short\n\ Fixed point format with 5 significant figures in a field that is a maximum\n\ of 10 characters wide. (default).\n\ \n\ If Octave is unable to format a matrix so that columns line up on the\n\ decimal point and all numbers fit within the maximum field width then\n\ it switches to an exponential @samp{e} format.\n\ \n\ @item long\n\ Fixed point format with 15 significant figures in a field that is a maximum\n\ of 20 characters wide.\n\ \n\ As with the @samp{short} format, Octave will switch to an exponential\n\ @samp{e} format if it is unable to format a matrix properly using the\n\ current format.\n\ \n\ @item short e\n\ @itemx long e\n\ Exponential format. The number to be represented is split between a mantissa\n\ and an exponent (power of 10). The mantissa has 5 significant digits in the\n\ short format and 15 digits in the long format.\n\ For example, with the @samp{short e} format, @code{pi} is displayed as\n\ @code{3.1416e+00}.\n\ \n\ @item short E\n\ @itemx long E\n\ Identical to @samp{short e} or @samp{long e} but displays an uppercase\n\ @samp{E} to indicate the exponent.\n\ For example, with the @samp{long E} format, @code{pi} is displayed as\n\ @code{3.14159265358979E+00}.\n\ \n\ @item short g\n\ @itemx long g\n\ Optimally choose between fixed point and exponential format based on\n\ the magnitude of the number.\n\ For example, with the @samp{short g} format,\n\ @code{pi .^ [2; 4; 8; 16; 32]} is displayed as\n\ \n\ @example\n\ @group\n\ ans =\n\ \n\ 9.8696\n\ 97.409\n\ 9488.5\n\ 9.0032e+07\n\ 8.1058e+15\n\ @end group\n\ @end example\n\ \n\ @item long G\n\ @itemx short G\n\ Identical to @samp{short g} or @samp{long g} but displays an uppercase\n\ @samp{E} to indicate the exponent.\n\ \n\ @item free\n\ @itemx none\n\ Print output in free format, without trying to line up columns of\n\ matrices on the decimal point. This also causes complex numbers to be\n\ formatted as numeric pairs like this @samp{(0.60419, 0.60709)} instead\n\ of like this @samp{0.60419 + 0.60709i}.\n\ @end table\n\ \n\ The following formats affect all numeric output (floating point and\n\ integer types).\n\ \n\ @table @code\n\ @item +\n\ @itemx + @var{chars}\n\ @itemx plus\n\ @itemx plus @var{chars}\n\ Print a @samp{+} symbol for nonzero matrix elements and a space for zero\n\ matrix elements. This format can be very useful for examining the\n\ structure of a large sparse matrix.\n\ \n\ The optional argument @var{chars} specifies a list of 3 characters to use\n\ for printing values greater than zero, less than zero and equal to zero.\n\ For example, with the @samp{+ \"+-.\"} format, @code{[1, 0, -1; -1, 0, 1]}\n\ is displayed as\n\ \n\ @example\n\ @group\n\ ans =\n\ \n\ +.-\n\ -.+\n\ @end group\n\ @end example\n\ \n\ @item bank\n\ Print in a fixed format with two digits to the right of the decimal\n\ point.\n\ \n\ @item native-hex\n\ Print the hexadecimal representation of numbers as they are stored in\n\ memory. For example, on a workstation which stores 8 byte real values\n\ in IEEE format with the least significant byte first, the value of\n\ @code{pi} when printed in @code{native-hex} format is @code{400921fb54442d18}.\n\ \n\ @item hex\n\ The same as @code{native-hex}, but always print the most significant\n\ byte first.\n\ @item native-bit\n\ Print the bit representation of numbers as stored in memory.\n\ For example, the value of @code{pi} is\n\ \n\ @example\n\ @group\n\ 01000000000010010010000111111011\n\ 01010100010001000010110100011000\n\ @end group\n\ @end example\n\ \n\ (shown here in two 32 bit sections for typesetting purposes) when\n\ printed in native-bit format on a workstation which stores 8 byte real values\n\ in IEEE format with the least significant byte first.\n\ @item bit\n\ The same as @code{native-bit}, but always print the most significant\n\ bits first.\n\ \n\ @item rat\n\ Print a rational approximation, i.e., values are approximated\n\ as the ratio of small integers.\n\ For example, with the @samp{rat} format,\n\ @code{pi} is displayed as @code{355/113}.\n\ @end table\n\ \n\ The following two options affect the display of all matrices.\n\ \n\ @table @code\n\ @item compact\n\ Remove extra blank space around column number labels producing more compact\n\ output with more data per page.\n\ @item loose\n\ Insert blank lines above and below column number labels to produce a more\n\ readable output with less data per page. (default).\n\ @end table\n\ @end deffn")
 DEFUN (fixed_point_format, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} fixed_point_format ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} fixed_point_format (@var{new_val})\n\ Query or set the internal variable that controls whether Octave will\n\ use a scaled format to print matrix values such that the largest\n\ element may be written with a single leading digit with the scaling\n\ factor is printed on the first line of output. For example,\n\ \n\ @example\n\ @group\n\ octave:1> logspace (1, 7, 5)'\n\ ans =\n\ \n\ 1.0e+07 *\n\ \n\ 0.00000\n\ 0.00003\n\ 0.00100\n\ 0.03162\n\ 1.00000\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ Notice that first value appears to be zero when it is actually 1. For\n\ this reason, you should be careful when setting\n\ @code{fixed_point_format} to a nonzero value.\n\ @end deftypefn")
 DEFUN (print_empty_dimensions, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} print_empty_dimensions ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} print_empty_dimensions (@var{new_val})\n\ Query or set the internal variable that controls whether the\n\ dimensions of empty matrices are printed along with the empty matrix\n\ symbol, @samp{[]}. For example, the expression\n\ \n\ @example\n\ zeros (3, 0)\n\ @end example\n\ \n\ @noindent\n\ will print\n\ \n\ @example\n\ ans = [](3x0)\n\ @end example\n\ @end deftypefn")
 DEFUN (split_long_rows, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} split_long_rows ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} split_long_rows (@var{new_val})\n\ Query or set the internal variable that controls whether rows of a matrix\n\ may be split when displayed to a terminal window. If the rows are split,\n\ Octave will display the matrix in a series of smaller pieces, each of\n\ which can fit within the limits of your terminal width and each set of\n\ rows is labeled so that you can easily see which columns are currently\n\ being displayed. For example:\n\ \n\ @example\n\ @group\n\ octave:13> rand (2,10)\n\ ans =\n\ \n\ Columns 1 through 6:\n\ \n\ 0.75883 0.93290 0.40064 0.43818 0.94958 0.16467\n\ 0.75697 0.51942 0.40031 0.61784 0.92309 0.40201\n\ \n\ Columns 7 through 10:\n\ \n\ 0.90174 0.11854 0.72313 0.73326\n\ 0.44672 0.94303 0.56564 0.82150\n\ @end group\n\ @end example\n\ @end deftypefn")
 DEFUN (output_max_field_width, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} output_max_field_width ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} output_max_field_width (@var{new_val})\n\ Query or set the internal variable that specifies the maximum width\n\ of a numeric output field.\n\ @seealso{format, output_precision}\n\ @end deftypefn")
 DEFUN (output_precision, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} output_precision ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} output_precision (@var{new_val})\n\ Query or set the internal variable that specifies the minimum number of\n\ significant figures to display for numeric output.\n\ @seealso{format, output_max_field_width}\n\ @end deftypefn")
 DEFUN (struct_levels_to_print, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} struct_levels_to_print ()\n\ @deftypefnx {Built-in Function} {@var{old_val} =} struct_levels_to_print (@var{new_val})\n\ Query or set the internal variable that specifies the number of\n\ structure levels to display.\n\ @end deftypefn")

Variables

bool Vprint_empty_dimensions = true
int Vstruct_levels_to_print = 2

Define Documentation

#define INSTANTIATE_ABS ( T   )     template /* static */ inline T abs (T)

#define PRINT_CHAR_BITS ( os,
 ) 

Value:

do \
    { \
      unsigned char ctmp = c; \
      char stmp[9]; \
      stmp[0] = (ctmp & 0x80) ? '1' : '0'; \
      stmp[1] = (ctmp & 0x40) ? '1' : '0'; \
      stmp[2] = (ctmp & 0x20) ? '1' : '0'; \
      stmp[3] = (ctmp & 0x10) ? '1' : '0'; \
      stmp[4] = (ctmp & 0x08) ? '1' : '0'; \
      stmp[5] = (ctmp & 0x04) ? '1' : '0'; \
      stmp[6] = (ctmp & 0x02) ? '1' : '0'; \
      stmp[7] = (ctmp & 0x01) ? '1' : '0'; \
      stmp[8] = '\0'; \
      os << stmp; \
    } \
  while (0)

#define PRINT_CHAR_BITS_SWAPPED ( os,
 ) 

Value:

do \
    { \
      unsigned char ctmp = c; \
      char stmp[9]; \
      stmp[0] = (ctmp & 0x01) ? '1' : '0'; \
      stmp[1] = (ctmp & 0x02) ? '1' : '0'; \
      stmp[2] = (ctmp & 0x04) ? '1' : '0'; \
      stmp[3] = (ctmp & 0x08) ? '1' : '0'; \
      stmp[4] = (ctmp & 0x10) ? '1' : '0'; \
      stmp[5] = (ctmp & 0x20) ? '1' : '0'; \
      stmp[6] = (ctmp & 0x40) ? '1' : '0'; \
      stmp[7] = (ctmp & 0x80) ? '1' : '0'; \
      stmp[8] = '\0'; \
      os << stmp; \
    } \
  while (0)

#define PRINT_CONV ( T1,
T2   ) 

Value:

template <> \
  class \
  octave_print_conv<T1> \
  { \
  public: \
    typedef T2 print_conv_type; \
  }

#define PRINT_INT_ARRAY_INTERNAL ( TYPE   ) 

Value:

OCTINTERP_API void \
  octave_print_internal (std::ostream& os, const intNDArray<TYPE>& nda, \
                         bool pr_as_read_syntax, int extra_indent) \
  { \
    octave_print_internal_template (os, nda, pr_as_read_syntax, extra_indent); \
  }

#define PRINT_INT_SCALAR_INTERNAL ( TYPE   ) 

Value:

#define PRINT_ND_ARRAY ( os,
nda,
NDA_T,
ELT_T,
MAT_T   ) 

#define SPECIALIZE_UABS ( T   ) 

Value:

template <> \
  /* static */ inline unsigned T \
  abs (unsigned T x) \
  { \
    return x; \
  }


Function Documentation

template<class T >
T abs ( T  x  )  [inline]

DEFUN ( struct_levels_to_print  ,
args  ,
nargout   
)

DEFUN ( output_precision  ,
args  ,
nargout   
)

DEFUN ( output_max_field_width  ,
args  ,
nargout   
)

DEFUN ( split_long_rows  ,
args  ,
nargout   
)

DEFUN ( print_empty_dimensions  ,
args  ,
nargout   
)

DEFUN ( fixed_point_format  ,
args  ,
nargout   
)

DEFUN ( format  ,
args   
)

DEFUN ( fdisp  ,
args   
)

DEFUN ( disp  ,
args  ,
nargout   
)

DEFUN ( rats  ,
args  ,
nargout   
)

INSTANTIATE_ABS ( long   ) 

INSTANTIATE_ABS ( int   ) 

INSTANTIATE_ABS ( short   ) 

INSTANTIATE_ABS ( signed  char  ) 

void octave_print_internal ( std::ostream ,
const Cell ,
bool  ,
int  ,
bool   
)

void octave_print_internal ( std::ostream os,
const Array< std::string > &  nda,
bool  pr_as_read_syntax,
int   
)

void octave_print_internal ( std::ostream os,
const std::string s,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const charNDArray nda,
bool  pr_as_read_syntax,
int  extra_indent,
bool  pr_as_string 
)

void octave_print_internal ( std::ostream os,
const charMatrix chm,
bool  pr_as_read_syntax,
int  ,
bool  pr_as_string 
)

void octave_print_internal ( std::ostream os,
const boolNDArray nda,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const boolMatrix bm,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const Range r,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const FloatComplexNDArray nda,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const FloatComplexDiagMatrix cm,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const FloatComplexMatrix cm,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const FloatComplex c,
bool  pr_as_read_syntax 
)

void octave_print_internal ( std::ostream os,
const FloatNDArray nda,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const FloatDiagMatrix m,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const FloatMatrix m,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
float  d,
bool  pr_as_read_syntax 
)

void octave_print_internal ( std::ostream os,
bool  d,
bool  pr_as_read_syntax 
)

void octave_print_internal ( std::ostream os,
const ComplexNDArray nda,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const PermMatrix m,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const ComplexDiagMatrix cm,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const ComplexMatrix cm,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const Complex c,
bool   
)

void octave_print_internal ( std::ostream os,
const NDArray nda,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const DiagMatrix m,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
const Matrix m,
bool  pr_as_read_syntax,
int  extra_indent 
)

void octave_print_internal ( std::ostream os,
double  d,
bool   
)

template<class T >
void octave_print_internal_template ( std::ostream os,
const intNDArray< T > &  nda,
bool  pr_as_read_syntax,
int  extra_indent 
) [inline]

template<class T >
void octave_print_internal_template ( std::ostream os,
const octave_int< T > &  val,
bool   
) [inline]

std::ostream& operator<< ( std::ostream os,
const pr_rational_float prf 
)

std::ostream& operator<< ( std::ostream os,
const pr_formatted_float pff 
)

template void pr_int ( std::ostream ,
const octave_int8 ,
int   
)

template<class T >
void pr_int ( std::ostream os,
const T d,
int  fw = 0 
) [inline]

template<>
void pr_plus_format ( std::ostream os,
const Complex c 
) [inline]

template<class T >
void pr_plus_format ( std::ostream os,
const T val 
) [inline]

PRINT_CONV ( octave_int8  ,
octave_int16   
)


Variable Documentation