Commit 90fb0e60 authored by Gerrit Renker's avatar Gerrit Renker Committed by Arnaldo Carvalho de Melo

[DCCP] tfrc: Fix small error in reverse lookup of p for given f(p)

This fixes the following small error in tfrc_calc_x_reverse_lookup.

 1) The table is generated by the following equations:
	lookup[index][0] = g((index+1) * 1000000/TFRC_CALC_X_ARRSIZE);
	lookup[index][1] = g((index+1) * TFRC_CALC_X_SPLIT/TFRC_CALC_X_ARRSIZE);
    where g(q) is 1E6 * f(q/1E6)

 2) The reverse lookup assigns an entry in lookup[index][small]

 3) This index needs to match the above, i.e.
    * if small=0 then

      		p  = (index + 1) * 1000000/TFRC_CALC_X_ARRSIZE

    * if small=1 then

		p = (index+1) * TFRC_CALC_X_SPLIT/TFRC_CALC_X_ARRSIZE

These are exactly the changes that the patch makes; previously the code did
not conform to the way the lookup table was generated (this difference resulted
in a mean error of about 1.12%).
Signed-off-by: default avatarGerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: default avatarIan McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent 50ab46c7
...@@ -667,9 +667,9 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue) ...@@ -667,9 +667,9 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue)
ctr++; ctr++;
if (small) if (small)
return TFRC_CALC_X_SPLIT * ctr / TFRC_CALC_X_ARRSIZE; return (ctr + 1) * TFRC_CALC_X_SPLIT / TFRC_CALC_X_ARRSIZE;
else else
return 1000000 * ctr / TFRC_CALC_X_ARRSIZE; return (ctr + 1) * 1000000 / TFRC_CALC_X_ARRSIZE;
} }
EXPORT_SYMBOL_GPL(tfrc_calc_x_reverse_lookup); EXPORT_SYMBOL_GPL(tfrc_calc_x_reverse_lookup);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment