Real
SplineInterpolationBase::sampleDerivative(const std::vector<Real> & x, const std::vector<Real> & y, const std::vector<Real> & y2, Real x_int) const
{
  unsigned int klo, khi;
  findInterval(x, x_int, klo, khi);

  Real h, a, b;
  computeCoeffs(x, klo, khi, x_int, h, a, b);

  return (y[khi] - y[klo]) / h - (((3.0 * a*a - 1.0) * y2[klo] + (3.0 * b*b - 1.0) * -y2[khi]) * h / 6.0);
}
Real
SplineInterpolationBase::sample2ndDerivative(const std::vector<Real> & x, const std::vector<Real> & y, const std::vector<Real> & y2, Real x_int) const
{
  unsigned int klo, khi;
  findInterval(x, x_int, klo, khi);

  Real h, a, b;
  computeCoeffs(x, klo, khi, x_int, h, a, b);

  return a * y2[klo] + b * y2[khi];
}
Real
SplineInterpolationBase::sample(const std::vector<Real> & x, const std::vector<Real> & y, const std::vector<Real> & y2, Real x_int) const
{
  unsigned int klo, khi;
  findInterval(x, x_int, klo, khi);

  Real h, a, b;
  computeCoeffs(x, klo, khi, x_int, h, a, b);

  return a * y[klo] + b * y[khi] + ((a*a*a - a) * y2[klo] + (b*b*b - b) * y2[khi]) * (h*h) / 6.0;
}
예제 #4
0
double
SplineInterpolation::sample2ndDerivative(double x) const
{
  unsigned int klo, khi;
  findInterval(x, klo, khi);

  double h, a, b;
  computeCoeffs(klo, khi, x, h, a, b);

  return a * _y2[klo] + b * _y2[khi];
}
예제 #5
0
double
SplineInterpolation::sampleDerivative(double x) const
{
  unsigned int klo, khi;
  findInterval(x, klo, khi);

  double h, a, b;
  computeCoeffs(klo, khi, x, h, a, b);

  return (_y[khi] - _y[klo]) / h - (((3.0 * a*a - 1.0) * _y2[klo] + (3.0 * b*b - 1.0) * -_y2[khi]) * h / 6.0);
}
예제 #6
0
double
SplineInterpolation::sample(double x) const
{
  unsigned int klo, khi;
  findInterval(x, klo, khi);

  double h, a, b;
  computeCoeffs(klo, khi, x, h, a, b);

  return a * _y[klo] + b * _y[khi] + ((a*a*a - a) * _y2[klo] + (b*b*b - b) * _y2[khi]) * (h*h) / 6.0;
}
예제 #7
0
void init(int nTerms, int mid)
{
    a = malloc( nTerms*sizeof(struct Complex*) );
    b = malloc( nTerms*sizeof(struct Complex*) );
	int i;
	for (i = 0; i < nTerms; i++)
	{
		a[i] = malloc( nTerms*sizeof(struct Complex) );
        b[i] = malloc( nTerms*sizeof(struct Complex) );
	}
    computeCoeffs(a, nTerms, mid, INV_SQRT_2);
	CORR_LENGTH2 = CORR_LENGTH*CORR_LENGTH;
	SIGMA = sqrt(VARIANCE);
    SQRT_dT_OVER_CORRTIME = sqrt(dt / CORR_TIME);
    TIME_DECAY = 1.0 - dt / CORR_TIME;
}
예제 #8
0
double computeB(int nTerms, int mid)
{
    computeCoeffs(b, nTerms, mid, SQRT_dT_OVER_CORRTIME);
}
예제 #9
0
SeriesSmoother::SeriesSmoother(int coeffCount, int pointCount)
    : m_coeffCount(coeffCount), m_pointCount(pointCount)
{
    // Compute the coefficients
    computeCoeffs();
}