changeset 2564:f506b0b2eb82 octave-forge

Changes to huffmandict in the floating pt / double comparison to 1
author gnumuthu
date Tue, 03 Oct 2006 01:06:57 +0000
parents 9fbe2fdfc7cc
children 9674346902ee
files main/comm/inst/huffmandict.m main/comm/inst/shannonfanodict.m
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/main/comm/inst/huffmandict.m	Mon Oct 02 22:06:03 2006 +0000
+++ b/main/comm/inst/huffmandict.m	Tue Oct 03 01:06:57 2006 +0000
@@ -80,7 +80,8 @@
     minvar=0;
   end
   
-  if(sum(source_prob)!=1.0)
+  %need to compare to 1
+  if((sum(source_prob)-1.0) > 1e-7 )
     error("source probabilities must add up to 1.0");
   end
 
--- a/main/comm/inst/shannonfanodict.m	Mon Oct 02 22:06:03 2006 +0000
+++ b/main/comm/inst/shannonfanodict.m	Tue Oct 03 01:06:57 2006 +0000
@@ -69,10 +69,9 @@
   #
   #printf("Shannon Codes\n");
   #data_table=zeros(1,DMAX);
-
    cw_list={};
    for i=1:DMAX
-     if(P(i)>0)
+     if(P(i)~=0)
        digits=ceil(-log2(P(i))); #somany digits needed.
      else
        digits=0; #dont assign digits for zero probability symbols.