1 ## Copyright (C) 2004 Josep Mones i Teixidor
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {@var{B} = } uintlut (@var{A},@var{LUT})
18 ## Computes matrix B by using A as an index to lookup table LUT.
20 ## B = uintlut(A, LUT) calculates a matrix B by using @var{LUT} as a
21 ## lookup table indexed by values in @var{A}.
23 ## B class is the same as @var{LUT}.
26 ## Author: Josep Mones i Teixidor <jmones@puntbarra.com>
28 function B = uintlut(A, LUT)
30 usage("B = uintlut(A, LUT)");
33 ## We convert indexing array A to double since even CVS version of
34 ## Octave is unable to use non-double arrays as indexing types. This
35 ## won't be needed in the future eventually.
40 %! uintlut(uint8([1,2,3,4]),uint8([255:-1:0]));
41 %! % Returns a uint8 array [255,254,253,252]
43 %!assert(uintlut(uint8([1,2,3,4]),uint8([255:-1:0])), uint8([255:-1:252]));
44 %!assert(uintlut(uint16([1,2,3,4]),uint16([255:-1:0])), uint16([255:-1:252]));
45 %!assert(uintlut(uint32([1,2,3,4]),uint32([255:-1:0])), uint32([255:-1:252]));
46 %!assert(uintlut(uint64([1,2,3,4]),uint64([255:-1:0])), uint64([255:-1:252]));
50 % Revision 1.2 2007/03/23 16:14:38 adb014
51 % Update the FSF address
53 % Revision 1.1 2006/08/20 12:59:36 hauberg
54 % Changed the structure to match the package system
56 % Revision 1.2 2004/08/11 15:04:59 pkienzle
57 % Convert dos line endings to unix line endings
59 % Revision 1.1 2004/08/08 21:20:25 jmones
60 % uintlut and padarray functions added