Bug 98515

Summary: Skip mode fencepost errors
Product: [Applications] kst Reporter: Netterfield <netterfield>
Component: generalAssignee: George Staikos <staikos>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: case 1
case 2
case 3
What I have for skip

Description Netterfield 2005-02-03 18:36:17 UTC
Version:           1.1.0_devel (using KDE 3.3.0, SuSE)
Compiler:          gcc version 3.3.4 (pre 3.3.5 20040809)
OS:                Linux (i686) release 2.6.8-24.11-default

skip is borked.
Demo:
make a plot of a dirfile_maker file
2 curves both with points but no lines for clarity
  10 frames of sine, no skip
  10 frames of sine, with skip set. (need a second INDEX vector for X)
We will change starting frame and the skip value for curve 2

Case 1: starting frame = 0 and skip = 1 for both vectors of curve 2
        everything seems fine: curve 2 has the 1st sample of each frame

Case 2: starting frame = 10 (anything !=0), curve 2 skip = 1
        The X (INDEX) vector seems to have the correct value,
        but the Y (sine) vector seems to be shifted by by ~19 samples


Case 3: starting frame = 10 (anything !=0), curve 2 skip = 2
        X and Y vectors are both shifted, so the points are correct,
        but start 1 frame early, and end 1 frame early
Comment 1 Netterfield 2005-02-03 18:38:52 UTC
Created attachment 9413 [details]
case 1
Comment 2 Netterfield 2005-02-03 18:39:29 UTC
Created attachment 9414 [details]
case 2
Comment 3 Netterfield 2005-02-03 18:39:59 UTC
Created attachment 9415 [details]
case 3
Comment 4 George Staikos 2005-02-03 22:28:27 UTC
Investigating
Comment 5 George Staikos 2005-02-03 22:33:21 UTC
Note: this is specific to SPF!=1 right?
Comment 6 George Staikos 2005-02-07 22:04:20 UTC
Created attachment 9472 [details]
What I have for skip

This is what I see.  Everything appears to line up just right.	Those curves
are with no skip, and skip=1, 2, 3.

Can you attach your data file so I can try to reproduce this with it?
Comment 7 Netterfield 2005-02-07 22:45:12 UTC
Yup.  That is case 1 above. "Everything seems fine".

Try starting at a frame other than frame 0 (case 2 and 3).

I was using the dirfile_writer output.
Comment 8 George Staikos 2005-02-08 01:54:10 UTC
CVS commit by staikos: 

seems to fix Skip alignment errors?  Please reopen with a new testcase if there
are still problems
BUG: 98515


  M +1 -1      kstrvector.cpp   1.79


--- kdeextragear-2/kst/kst/kstrvector.cpp  #1.78:1.79
@@ -468,5 +468,5 @@ KstObject::UpdateType KstRVector::doUpda
     // new_f0 == 0 results in (new_f0 - 1)/Skip being -0.x which rounds the
     // wrong way on us.  Therefore new_f0 == 0 is a special case.
-    new_f0 = new_f0 == 0 ? 0 : (((new_f0 - 1)/Skip) + 1) * Skip - 1;
+    new_f0 = new_f0 == 0 ? 0 : (((new_f0 - 1)/Skip) + 1) * Skip;
     new_nf = tmp_fn - new_f0 + 1;
   }