From: Muthu <gnu...@us...> - 2006-10-09 16:16:26
|
Update of /cvsroot/octave/octave-forge/main/comm/inst In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5378 Modified Files: huffmandict.m Log Message: huffmandict updated to perform as wanted in the mailing list: with code-words for zero probability symbols, eventhough I wouldnt do it myself, and moreover its 'canonical huffman' which I think warrants this Index: huffmandict.m =================================================================== RCS file: /cvsroot/octave/octave-forge/main/comm/inst/huffmandict.m,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- huffmandict.m 8 Oct 2006 19:48:28 -0000 1.6 +++ huffmandict.m 9 Oct 2006 16:15:35 -0000 1.7 @@ -88,8 +88,11 @@ % %need to find & eliminate the zero-probability code words. %in practice we donot need to assign anything to them. Reasoning - %being that if it doesnt occur why bother saving its vale anyway? - % + %being that if_ it doesnt occur why bother saving its value anyway? + %--(Oct 9) Actually some experts in the area dont agree to this, + %and being a generic implementation we should stick to generating + %CW's for_ zero symbols. Why impose a bad implementation? --Muthu + % origsource_prob=source_prob; @@ -112,15 +115,6 @@ end end - %index - %source_prob - - idx=find(source_prob==0); - if(not(isempty(idx))) - source_prob=source_prob(1:idx(1)-1); - end - clear idx; - stage_list={}; cw_list{1:L}=[]; @@ -234,4 +228,5 @@ %! %!assert(huffmandict(1:4,[0.5 0.25 0.15 0.1],1), {[0],[1 0],[1 1 1],[1 1 0]},0) %!assert(huffmandict(1:4,0.25*ones(1,4),1),{[1 1],[1 0],[0 1],[0 0]},0) +%!assert(huffmandict(1:4,[1 0 0 0 ]),{[1],[0 1],[0 0 0],[0 0 1]},0) %! |