This file is indexed.

/usr/share/octave/packages/communications-1.2.1/randint.m is in octave-communications-common 1.2.1-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
## Copyright (C) 2001 Laurent Mazet
##
## 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 -*-
## @deftypefn  {Function File} {@var{b} =} randint (@var{n})
## @deftypefnx {Function File} {@var{b} =} randint (@var{n}, @var{m})
## @deftypefnx {Function File} {@var{b} =} randint (@var{n}, @var{m}, @var{range})
## @deftypefnx {Function File} {@var{b} =} randint (@var{n}, @var{m}, @var{range}, @var{seed})
##
## Generate a matrix of random binary numbers. The size of the matrix is
## @var{n} rows by @var{m} columns. By default @var{m} is equal to @var{n}.
##
## The range in which the integers are generated will is determined by
## the variable @var{range}. If @var{range} is an integer, the value will
## lie in the range [0,@var{range}-1], or [@var{range}+1,0] if @var{range}
## is negative. If @var{range} contains two elements the integers will lie
## within these two elements, inclusive. By default @var{range} is
## assumed to be [0:1].
##
## The variable @var{seed} allows the random number generator to be seeded
## with a fixed value. The initial seed will be restored when returning.
## @end deftypefn

function b = randint (n, m, range, seed)

  switch (nargin)
    case 1
      m = n;
      range = [0, 1];
      seed = Inf;
    case 2
      range = [0, 1];
      seed = Inf;
    case 3
      seed = Inf;
    case 4
    otherwise
      print_usage ();
  endswitch

  ## Check range
  if (length (range) == 1)
    if (range < 0)
      range = [range+1, 0];
    else
      range = [0, range-1];
    endif
  elseif ( prod (size (range)) != 2)
    error ("randint: RANGE must be a scalar or a 2-element vector");
  endif
  range = sort (range);

  ## Check seed;
  if (!isinf (seed))
    old_seed = rand ("seed");
    rand ("seed", seed);
  endif

  b = range (1) - 1 + ceil (rand (n, m) * (range (2) - range (1) + 1));

  ## Get back to the old
  if (!isinf (seed))
    rand ("seed", old_seed);
  endif

endfunction

%!shared n, m, seed, a1, a2, a3, a4, a5, a6
%!    n = 10; m = 32; seed = 1; a1 = randint (n); a2 = randint (n, n);
%!    a3 = randint (n, n, m); a4 = randint (n, n, [-m, m]);
%!    a5 = randint (n, n, m, seed); a6 = randint (n, n, m, seed);

%!error randint ();
%!error randint (n, n, n, n, n);
%!assert (size (a1) == [n, n] && size (a2) == [n, n]);
%!assert (max ([a1(:); a2(:)]) <= 1 && min ([a1(:); a2(:)]) >= 0);
%!assert (size (a3) == [n, n] && size (a4) == [n, n]);
%!assert (max (a3(:)) < m && min (a3(:)) >= 0);
%!assert (max (a4(:)) <= m && min (a4(:)) >= -m);
%!assert (a5(:) == a6(:));

%!test
%! a = randint (10, 10, -32);
%! assert (max (a(:)) <= 0 && min (a(:)) > -32);

%% Test input validation
%!error randint (1, 2, 3, 4, 5)
%!error randint (1, 1, [1 2 3])