当前位置: 首页>>代码示例>>C++>>正文


C++ VectorPtr::interpolate方法代码示例

本文整理汇总了C++中VectorPtr::interpolate方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorPtr::interpolate方法的具体用法?C++ VectorPtr::interpolate怎么用?C++ VectorPtr::interpolate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VectorPtr的用法示例。


在下文中一共展示了VectorPtr::interpolate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: point

void Curve::point(int i, double &x, double &y) const {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:10,代码来源:curve.cpp

示例2: getEYMinusPoint

void Curve::getEYMinusPoint(int i, double &x, double &y, double &ey) {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
  VectorPtr eyv = yMinusErrorVector();
  if (eyv) {
    ey = eyv->interpolate(i, NS);
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:14,代码来源:curve.cpp

示例3: getEXMinusPoint

void Curve::getEXMinusPoint(int i, double &x, double &y, double &ex) {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
  VectorPtr exmv = xMinusErrorVector();
  if (exmv) {
    ex = exmv->interpolate(i, NS);
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:14,代码来源:curve.cpp

示例4: getEYPoints

void Curve::getEYPoints(int i, double &x, double &y, double &eyminus, double &eyplus) {
  VectorPtr xv = xVector();
  if (xv) {
    x = xv->interpolate(i, NS);
  }
  VectorPtr yv = yVector();
  if (yv) {
    y = yv->interpolate(i, NS);
  }
  VectorPtr eyv = yErrorVector();
  if (eyv) {
    eyplus = eyv->interpolate(i, NS);
  }
  VectorPtr eymv = yMinusErrorVector();
  if (eymv) {
    eyminus = eymv->interpolate(i, NS);
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:18,代码来源:curve.cpp

示例5: getIndexNearXY

/** getIndexNearXY: return index of point within (or closest too)
    x +- dx which is closest to y **/
int Curve::getIndexNearXY(double x, double dx_per_pix, double y) const {
  VectorPtr xv = *_inputVectors.find(XVECTOR);
  VectorPtr yv = *_inputVectors.find(YVECTOR);
  if (!xv || !yv) {
    return 0; // anything better we can do?
  }

  double xi, yi, dx, dxi, dy, dyi;
  bool first = true;
  int i,i0, iN, index;
  int sc = sampleCount();

  if (xv->isRising()) {
    iN = i0 = indexNearX(x, xv, NS);

    xi = xv->interpolate(i0, NS);
    while (i0 > 0 && x-dx_per_pix < xi) {
      xi = xv->interpolate(--i0, NS);
    }

    xi = xv->interpolate(iN, NS);
    while (iN < sc-1 && x+dx_per_pix > xi) {
      xi = xv->interpolate(++iN, NS);
    }
  } else {
    i0 = 0;
    iN = sampleCount()-1;
  }

  index = i0;
  xi = xv->interpolate(index, NS);
  yi = yv->interpolate(index, NS);
  dx = fabs(x - xi);
  dy = fabs(y - yi);

  for (i = i0 + 1; i <= iN; i++) {
    xi = xv->interpolate(i, NS);
    dxi = fabs(x - xi);
    if (dxi < dx_per_pix) {
      dx = dxi;
      yi = yv->interpolate(i, NS);
      dyi = fabs(y - yi);
      if (first || dyi < dy) {
        first = false;
        index = i;
        dy = dyi;
      }
    } else if (dxi < dx) {
      dx = dxi;
      index = i;
    }
  }
  return index;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:56,代码来源:curve.cpp

示例6: indexNearX

inline int indexNearX(double x, VectorPtr& xv, int NS) {
  // monotonically rising: we can do a binary search
  // should be reasonably fast
  if (xv->isRising()) {
    int i_top = NS - 1;
    int i_bot = 0;

    // don't pre-check for x outside of the curve since this is not
    // the common case.  It will be correct - just slightly slower...
    while (i_bot + 1 < i_top) {
      int i0 = (i_top + i_bot)/2;
      double rX = xv->interpolate(i0, NS);
      if (x < rX) {
        i_top = i0;
      } else {
        i_bot = i0;
      }
    }
    double xt = xv->interpolate(i_top, NS);
    double xb = xv->interpolate(i_bot, NS);
    if (xt - x < x - xb) {
      return i_top;
    } else {
      return i_bot;
    }
  } else {
    // Oh Oh... not monotonically rising - we have to search the entire curve!
    // May be unbearably slow for large vectors
    double rX = xv->interpolate(0, NS);
    double dx0 = fabs(x - rX);
    int i0 = 0;

    for (int i = 1; i < NS; ++i) {
      rX = xv->interpolate(i, NS);
      double dx = fabs(x - rX);
      if (dx < dx0) {
        dx0 = dx;
        i0 = i;
      }
    }
    return i0;
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:43,代码来源:curve.cpp


注:本文中的VectorPtr::interpolate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。