Beispiel #1
0
int main(int argc, char* argv[])
{
  IupOpen(&argc, &argv);

  SplitTest();

  IupMainLoop();

  IupClose();

  return EXIT_SUCCESS;
}
Beispiel #2
0
static bool SmoothSplit3(const T *x, T *y, size_t n, bool do_ends) {
  // y[] := S(x[])  where S() = "sm_split3"
  bool chg = false;

  for (size_t i = 0; i < n; i++)
    y[i] = x[i];

  if (do_ends && SplitTest(x, 1)) {
    chg = true;
    y[1] = x[0];
    y[2] = MedianOf3(x[2], x[3], 3*x[3] - 2*x[4]);
  }

  for (size_t i = 2; i < n-3; i++) {
    if (SplitTest(x, i)) {
      int j;
      // plateau at x[i] == x[i+1]

      // at left:
      if (-1 < (j = IndexOfMedianOf3(x[i ], x[i-1], 3*x[i-1] - 2*x[i-2]))) {
        y[i]   =  (j == 0 ? x[i-1] : 3*x[i-1] - 2*x[i-2]);
        chg = (y[i] != x[i]);
      }
      
      // at right:
      if (-1 < (j = IndexOfMedianOf3(x[i+1], x[i+2], 3*x[i+2] - 2*x[i+3]))) {
        y[i+1] = (j == 0 ? x[i+2] : 3*x[i+2] - 2*x[i+3]);
        chg = (y[i+1] != x[i+1]);
      }
    }
  }
  
  if (do_ends && SplitTest(x, n-3)) {
    chg = true;
    y[n-2] = x[n-1];
    y[n-3] = MedianOf3(x[n-3], x[n-4], 3*x[n-4] - 2*x[n-5]);
  }
  
  return chg;
}