This file is indexed.

/usr/share/octave/packages/interval-2.1.0/@infsup/bisect.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
## Copyright 2015-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
## @deftypemethod {@@infsup} {[@var{A}, @var{B}] =} bisect (@var{X})
##
## Bisect an interval into two intervals, which contain half the amount of
## binary64 numbers each.
##
## Instead of bisecting the values of numbers in the interval at
## @code{mid (@var{X})}, this function bisects a function that counts them.  In
## a bisect method this eliminates exactly half of the solutions and avoids
## slow convergence speeds in extreme cases.
##
## If all numbers in interval @var{X} are of equal sign, the pivot element used
## for bisection is @code{pow2 (mid (log2 (abs (@var{X}))))}.  If @var{X} is no
## empty interval, the intervals @var{A} and @var{B} are non-empty and satisfy
## @code{@var{A}.sup == @var{B}.inf}.
##
## @example
## @group
## [a, b] = bisect (infsup (2, 32))
##   @result{} 
##     a = [2, 8]
##     b = [8, 32]
## @end group
## @end example
## @seealso{@@infsup/mince, @@infsup/nextout}
## @end deftypemethod

## Author: Oliver Heimlich
## Keywords: interval
## Created: 2015-05-25

function [a, b] = bisect (x)

if (nargin > 1)
    print_usage ();
    return
endif

m = zeros (size (x.inf));
idx.type = '()';

positive = x.inf >= 0 & x.sup > 0;
if (any (positive(:)))
    idx.subs = {positive};
    bounded = intersect (infsup (pow2 (-1074), realmax), subsref (x, idx));
    m(positive) = min (realmax, pow2 (mid (log2 (bounded))));
endif

negative = x.inf < 0 & x.sup <= 0;
if (any (negative(:)))
    idx.subs = {negative};
    bounded = intersect (infsup (-realmax, -pow2 (-1074)), subsref (x, idx));
    m(negative) = ...
        uminus (min (realmax, pow2 (mid (log2 (uminus (bounded))))));
endif

both_signs = x.inf < 0 & x.sup > 0;
both_signs_p = both_signs & x.sup > -x.inf;
if (any (both_signs_p(:)))
    idx.subs = {both_signs_p};
    bounded_n = intersect (infsup (-realmax, -pow2 (-1074)), subsref (x, idx));
    bounded_p = intersect (infsup (pow2 (-1074), realmax), subsref (x, idx));
    m(both_signs_p) = min (realmax, pow2 (
        mid (log2 (bounded_p)) ...
        - mid (log2 (uminus (bounded_n))) ...
        - 1074));
endif

both_signs_n = both_signs & x.sup < -x.inf;
if (any (both_signs_n(:)))
    idx.subs = {both_signs_n};
    bounded_n = intersect (infsup (-realmax, -pow2 (-1074)), subsref (x, idx));
    bounded_p = intersect (infsup (pow2 (-1074), realmax), subsref (x, idx));
    m(both_signs_n) = uminus (min (realmax, pow2 (
        mid (log2 (uminus (bounded_n))) ...
        - mid (log2 (bounded_p)) ...
        - 1074)));
endif

m = min (max (m, x.inf), x.sup);

a = b = x;
m(isempty (x)) = -inf;
a.sup = m;
m(isempty (x)) = inf;
m(m == 0) = -0;
b.inf = m;

endfunction

%!test
%! # from the documentation string
%! [a, b] = bisect (infsup (2, 32));
%! assert (a == infsup (2, 8));
%! assert (b == infsup (8, 32));
%!test
%! [a, b] = bisect (infsup (-inf, inf));
%! assert (a == infsup (-inf, 0));
%! assert (b == infsup (0, inf));
%!test
%! [a, b] = bisect (infsup (0));
%! assert (a == 0);
%! assert (b == 0);
%!test
%! [a, b] = bisect (infsup ());
%! assert (isempty (a));
%! assert (isempty (b));
%!test
%! [a, b] = bisect (infsup (0, inf));
%! assert (a == infsup (0, pow2 (-25)));
%! assert (b == infsup (pow2 (-25), inf));
%!test
%! [a, b] = bisect (infsup (-inf, 0));
%! assert (a == infsup (-inf, -pow2 (-25)));
%! assert (b == infsup (-pow2 (-25), 0));
%!# correct use of signed zeros
%!test
%! [a, b] = bisect (infsup (0));
%! assert (signbit (inf (a)));
%! assert (signbit (inf (b)));
%! assert (not (signbit (sup (a))));
%! assert (not (signbit (sup (b))));