/usr/share/octave/packages/communications-1.2.1/fiboenco.m is in octave-communications-common 1.2.1-5.
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 | ## Copyright (C) 2006 Muthiah Annamalai <muthiah.annamalai@uta.edu>
##
## 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} {} fiboenco (@var{num})
##
## Returns the cell-array of encoded Fibonacci value from the column vectors @var{num}.
## Universal codes like Fibonacci codes have a useful synchronization
## property, only for 255 maximum value we have designed these routines. We assume
## user has partitioned the code into several unique segments based on
## the suffix property of unique elements [1 1] and we just decode the
## parts. Partitioning the stream is as simple as identifying the [1 1]
## pairs that occur, at the terminating ends. This system implements
## the standard binary Fibonacci codes, which means that row vectors
## can only contain 0 or 1. Ref: http://en.wikipedia.org/wiki/Fibonacci_coding
## Ugly O(k.N^2) encoder.Ref: Wikipedia article accessed March, 2006.
## @url{http://en.wikipedia.org/wiki/Fibonacci_coding}, UCI Data Compression
## Book, @url{http://www.ics.uci.edu/~dan/pubs/DC-Sec3.html}, (accessed
## October 2006)
##
## @example
## @group
## fiboenco (10)
## @result{} @{[ 0 1 0 0 1 1]@}
## fiboenco (1:4)
## @result{} @{[1 1], [0 1 1], [0 0 1 1], [1 0 1 1]@}
## @end group
## @end example
## @seealso{fibodeco}
## @end deftypefn
function op_num = fiboenco (num)
##
## generate fibonacci series table.
##
## f(1)=1;
## f(2)=1;
##
## while ((f(end-1)+f(end)) < 256)
## val=(f(end-1)+f(end));
## f=[f val];
## endwhile
## f=sort(f(2:end),"descend");
##
## f= [75025 46368 28657 17711 10946 6765 4181 2584 \
## 1597 987 610 377 233 144 89 55 \
## 34 21 13 8 5 3 2 1];
if (nargin != 1 || min (num) <= 0 || max (num) > 608)
print_usage ();
endif
f = [233 144 89 55 34 21 13 8 5 3 2 1];
onum = num;
LEN_F = length (f);
LEN_N = length (num);
for j = 1:LEN_N
N = num(j);
rval = [];
## create Fibonacci encoding of a number
for i = find (f <= N):LEN_F
if (N >= f(i))
N = N-f(i);
rval = [1 rval];
else
rval = [0 rval];
endif
endfor
op_num{j} = [rval 1];
endfor
endfunction
%!assert (fibodeco (fiboenco (1:600)), [1:600])
%% Test input validation
%!error fiboenco ()
%!error fiboenco (1, 2)
%!error fiboenco (0)
%!error fiboenco (1000)
|