[Kst] [PATCH] skip off-by-one
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Sep 22 19:28:14 CEST 2005
The new code is wrong. It always rounds down, even if you start on a skip
boundry:
new_f0 = 2, skip = 2:
old: ((2-1)/2 + 1) *2 = 2
new: (2-1)/2*2 = 0
new_f0 = 1, skip = 2
old: ((1-1)/2 + 1) * 2 = 2;
new: (1-1)/2*2 = 0;
new_f0 = 0 skip = 1 (eg, more than 1 spf, want only 1 spf)
old: (0-1)/1+1) * 1= 0
new: (0-1)/1 * 1 = -1
The new code rounds up to the next skip boundry. The only trouble with this
might come if new_f0 between the last skip boundry and the end of the file.
Check the nf calculations...
cbn
On September 22, 2005 09:07 am, George Staikos wrote:
> I haven't tested this enough to feel comfortable about it yet so I'd like
> some feedback. I think we have an off-by-one bug in skip mode. On planck
> data we were seeing occasional cases where the last value in the vector was
> not populated on an update, but there clearly was enough data for it. This
> resulted in "going back in time" in the index/time vector, causing a line
> across the graph. This patch fixes it. The /Skip*Skip is necessary to get
> the integer rounding correct. I will comment that before I commit.
>
> Index: kstrvector.cpp
> ===================================================================
> --- kstrvector.cpp (revision 462954)
> +++ kstrvector.cpp (working copy)
> @@ -468,7 +468,7 @@
> if (DoSkip) {
> // change new_f0 and new_nf so they both lie on skip boundaries
> if (new_f0 != 0) {
> - new_f0 = (((new_f0-1)/Skip)+1)*Skip;
> + new_f0 = (new_f0-1)/Skip*Skip;
> }
> new_nf = (new_nf/Skip)*Skip;
> }
More information about the Kst
mailing list