/usr/share/octave/packages/interval-2.1.0/@infsup/display.m is in octave-interval 2.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | ## Copyright 2014-2016 Oliver Heimlich
##
## 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
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program 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/>.
## -*- texinfo -*-
## @documentencoding UTF-8
## @defmethod {@@infsup} display (@var{X})
##
## Display the variable name and value of interval @var{X}.
##
## Interval boundaries are approximated with faithful decimal numbers.
##
## If @var{X} is a variable, the interval is display together with its variable
## name. The variable name is followed by an equality sign if all decimal
## boundaries exactly represent the actual boundaries. Otherwise a subset
## symbol is used instead (this feature is not available on Microsoft Windows).
##
## For non-scalar intervals the size and classification (interval vector or
## interval matrix) is displayed before the content.
##
## @example
## @group
## display (infsupdec (2));
## @result{} [2]_com
## @end group
## @end example
## @example
## @group
## x = infsupdec (2); display (x);
## @result{} x = [2]_com
## @end group
## @end example
## @example
## @group
## y = infsupdec (eps); display (y);
## @result{} y ⊂ [2.2204e-16, 2.2205e-16]_com
## @end group
## @end example
## @example
## @group
## z = infsupdec (pascal (2)); display (z);
## @result{} z = 2×2 interval matrix
## [1]_com [1]_com
## [1]_com [2]_com
## @end group
## @end example
## @seealso{@@infsup/disp, @@infsup/intervaltotext}
## @end defmethod
## Author: Oliver Heimlich
## Keywords: interval
## Created: 2014-10-28
function display (x)
if (nargin ~= 1)
print_usage ();
return
endif
global current_print_indent_level;
save_current_print_indent_level = current_print_indent_level;
unwind_protect
label = inputname (1);
if (isempty (label) && regexp(argn, '^\[\d+,\d+\]$'))
## During output of cell array contents
label = argn;
## FIXME: Need access to octave_value::current_print_indent_level
## for correctly formatted nested cell array output
current_print_indent_level = 2;
else
current_print_indent_level = 0;
endif
line_prefix = " "(ones (1, current_print_indent_level));
[s, isexact] = disp (x);
printf (line_prefix);
if (not (isempty (label)))
printf (label);
if (isexact || ispc ())
printf (" = ");
else
## The Microsoft Windows console does not support this multibyte
## character.
printf (" ⊂ ");
endif
endif
if (isscalar (x))
## Scalar interval
printf (s);
if (isempty (label))
printf ("\n");
endif
return
endif
if (ispc ())
printf ("%dx%d interval ", size (x, 1), size (x, 2));
else
## The Microsoft Windows console does not support multibyte characters.
printf ("%d×%d interval ", size (x, 1), size (x, 2));
endif
if (isvector (x))
printf ("vector");
else
printf ("matrix");
endif
printf ("\n\n");
if (not (isempty (s)))
printf (line_prefix);
if (current_print_indent_level > 0)
s = strrep (s, "\n", cstrcat ("\n", line_prefix));
s(end - current_print_indent_level + 1 : end) = "";
endif
printf (s);
printf ("\n");
endif
unwind_protect_cleanup
current_print_indent_level = save_current_print_indent_level;
end_unwind_protect
endfunction
%!# Can't test the display function. Would have to capture console output.
%!# However, this is largely done with the help of the doctest package.
%!assert (1);
|