Mercurial > forge
changeset 2548:3957a29325ed octave-forge
Index changed to reflect added rleenco & rledeco as when other-lead.. catches up
author | gnumuthu |
---|---|
date | Mon, 02 Oct 2006 06:45:44 +0000 |
parents | 83adcf40a3e4 |
children | 175fda85a1ba |
files | main/comm/INDEX main/comm/inst/rledeco.m main/comm/inst/rleenco.m |
diffstat | 3 files changed, 115 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/main/comm/INDEX Mon Oct 02 06:44:45 2006 +0000 +++ b/main/comm/INDEX Mon Oct 02 06:45:44 2006 +0000 @@ -21,8 +21,22 @@ huffmanenco lloyds quantiz + huffmandict + huffmanenco + huffmandeco + shannonfanodict + shannonfanoenco + shannonfanodeco + rleenco + rledeco +Block Interleavers + intrlv + algintrlv + helscanintrlv + matintrlv + randintrlv Block Coding - bchdeco + bchdeco bchenco bchpoly convenc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/comm/inst/rledeco.m Mon Oct 02 06:45:44 2006 +0000 @@ -0,0 +1,48 @@ +## (C) 2006, August, 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 2 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, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## + +## usage: rledeco(message) +## This function decodes a run-length encoded message into its +## original form. The encoded message has to be in the form of a +## row-vector. The message format (encoded RLE) is like repetition +## factor, value. +## +## example: +## message=[1 5 2 4 3 1]; +## rledeco(message) #gives +## ans = [ 5 4 4 1 1 1] +## +## see also: rleenco() +## +function rmsg=rledeco(message) + if nargin < 1 + error('Usage: rledeco(message)') + end + rmsg=[]; + L=length(message); + itr=1; + while itr < L + times=message(itr); + val=message(itr+1); + rmsg=[rmsg val*(ones(1,times))]; + itr=itr+2; + end + return +end +%! +%!assert( rledeco([1 5 2 4 3 1]),[5 4 4 1 1 1]) +%!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/comm/inst/rleenco.m Mon Oct 02 06:45:44 2006 +0000 @@ -0,0 +1,52 @@ +## (C) 2006, August, 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 2 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, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## + +## usage: rleenco(message) +## This function decodes a run-length encodes a message into its +## rle form. The original message has to be in the form of a +## row-vector. The message format (encoded RLE) is like repetition +## factor, value. +## +## example: +## message=[ 5 4 4 1 1 1] +## rleenco(message) #gives +## ans = [1 5 2 4 3 1]; +## +## +## see also: rledeco() +## +function rmsg=rleenco(message) + if nargin < 1 + error('Usage: rleenco(message)') + end + rmsg=[]; + L=length(message); + itr=1; + while itr <= L + times=0; + val=message(itr); + while(itr <= L && message(itr)==val) + itr=itr+1; + times=times+1; + end + rmsg=[rmsg times val]; + end + return +end +%! +%!assert( rleenco([5 4 4 1 1 1]),[1 5 2 4 3 1]) +%!