www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MonotoneCubicInterpolation Class Reference

This class interpolates values given a set of data pairs and an abscissa. More...

#include <MonotoneCubicInterpolation.h>

Public Member Functions

 MonotoneCubicInterpolation ()
 Empty constructor. More...
 
 MonotoneCubicInterpolation (const std::vector< Real > &x, const std::vector< Real > &y)
 Constructor, Takes two vectors of points for which to apply the fit. More...
 
virtual ~MonotoneCubicInterpolation ()=default
 
virtual void setData (const std::vector< Real > &x, const std::vector< Real > &y)
 Method generally used when MonotoneCubicInterpolation object was created using the empty constructor. More...
 
virtual Real sample (const Real &x) const
 This function will take an independent variable input and will return the dependent variable based on the generated fit. More...
 
virtual Real sampleDerivative (const Real &x) const
 This function will take an independent variable input and will return the derivative of the dependent variable with respect to the independent variable based on the generated fit. More...
 
virtual Real sample2ndDerivative (const Real &x) const
 This function will take an independent variable input and will return the second derivative of the dependent variable with respect to the independent variable based on the generated fit. More...
 
virtual void dumpCSV (std::string filename, const std::vector< Real > &xnew)
 This function takes an array of independent variable values and writes a CSV file with values corresponding to y, y', and y''. More...
 
virtual unsigned int getSampleSize ()
 This method returns the length of the independent variable vector. More...
 

Protected Member Functions

virtual void errorCheck ()
 
Real sign (const Real &x) const
 
Real phi (const Real &t) const
 
Real psi (const Real &t) const
 
Real phiPrime (const Real &t) const
 
Real psiPrime (const Real &t) const
 
Real phiDoublePrime (const Real &t) const
 
Real psiDoublePrime (const Real &t) const
 
Real h1 (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h2 (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h3 (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h4 (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h1Prime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h2Prime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h3Prime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h4Prime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h1DoublePrime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h2DoublePrime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h3DoublePrime (const Real &xhi, const Real &xlo, const Real &x) const
 
Real h4DoublePrime (const Real &xhi, const Real &xlo, const Real &x) const
 
virtual Real p (const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
 
virtual Real pPrime (const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
 
virtual Real pDoublePrime (const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
 
virtual void initialize_derivs ()
 
virtual void modify_derivs (const Real &alpha, const Real &beta, const Real &delta, Real &yp_lo, Real &yp_hi)
 
virtual void solve ()
 
virtual void findInterval (const Real &x, unsigned int &klo, unsigned int &khi) const
 

Protected Attributes

std::vector< Real > _x
 
std::vector< Real > _y
 
std::vector< Real > _h
 
std::vector< Real > _yp
 
std::vector< Real > _delta
 
std::vector< Real > _alpha
 
std::vector< Real > _beta
 
unsigned int _n_knots
 
unsigned int _n_intervals
 
unsigned int _internal_knots
 

Detailed Description

This class interpolates values given a set of data pairs and an abscissa.

The interpolation is cubic with at least C1 continuity; C2 continuity can be violated in favor of ensuring the interpolation is monotonic. The algorithm used is laid out in Fritsch and Carlson, SIAM J. Numer. Anal. Vol. 17(2) April 1980

Definition at line 31 of file MonotoneCubicInterpolation.h.

Constructor & Destructor Documentation

MonotoneCubicInterpolation::MonotoneCubicInterpolation ( )

Empty constructor.

Definition at line 24 of file MonotoneCubicInterpolation.C.

24 {}
MonotoneCubicInterpolation::MonotoneCubicInterpolation ( const std::vector< Real > &  x,
const std::vector< Real > &  y 
)

Constructor, Takes two vectors of points for which to apply the fit.

One should be of the independent variable while the other should be of the dependent variable. These values should have a one-to-one correspondence, e.g. the vectors must be of the same size.

Definition at line 26 of file MonotoneCubicInterpolation.C.

28  : _x(x), _y(y)
29 {
30  errorCheck();
31  solve();
32 }
static PetscErrorCode Vec x
virtual MonotoneCubicInterpolation::~MonotoneCubicInterpolation ( )
virtualdefault

Member Function Documentation

void MonotoneCubicInterpolation::dumpCSV ( std::string  filename,
const std::vector< Real > &  xnew 
)
virtual

This function takes an array of independent variable values and writes a CSV file with values corresponding to y, y', and y''.

This can be used for sanity checks of the interpolation curve.

Definition at line 375 of file MonotoneCubicInterpolation.C.

376 {
377  unsigned int n = xnew.size();
378  std::vector<Real> ynew(n), ypnew(n), yppnew(n);
379 
380  std::ofstream out(filename.c_str());
381  for (unsigned int i = 0; i < n; ++i)
382  {
383  ynew[i] = sample(xnew[i]);
384  ypnew[i] = sampleDerivative(xnew[i]);
385  yppnew[i] = sample2ndDerivative(xnew[i]);
386  out << xnew[i] << ", " << ynew[i] << ", " << ypnew[i] << ", " << yppnew[i] << "\n";
387  }
388  out.close();
389 }
virtual Real sample2ndDerivative(const Real &x) const
This function will take an independent variable input and will return the second derivative of the de...
virtual Real sampleDerivative(const Real &x) const
This function will take an independent variable input and will return the derivative of the dependent...
virtual Real sample(const Real &x) const
This function will take an independent variable input and will return the dependent variable based on...
PetscInt n
void MonotoneCubicInterpolation::errorCheck ( )
protectedvirtual

Definition at line 44 of file MonotoneCubicInterpolation.C.

Referenced by MonotoneCubicInterpolation(), and setData().

45 {
46  if (_x.size() != _y.size())
47  throw std::domain_error("MonotoneCubicInterpolation: x and y vectors are not the same length");
48 
49  bool error = false;
50  for (unsigned i = 0; !error && i + 1 < _x.size(); ++i)
51  if (_x[i] >= _x[i + 1])
52  error = true;
53 
54  if (error)
55  throw std::domain_error("x-values are not strictly increasing");
56 }
void MonotoneCubicInterpolation::findInterval ( const Real &  x,
unsigned int &  klo,
unsigned int &  khi 
) const
protectedvirtual

Definition at line 330 of file MonotoneCubicInterpolation.C.

Referenced by sample(), sample2ndDerivative(), and sampleDerivative().

333 {
334  klo = 0;
335  khi = _n_knots - 1;
336  while (khi - klo > 1)
337  {
338  unsigned int k = (khi + klo) >> 1;
339  if (_x[k] > x)
340  khi = k;
341  else
342  klo = k;
343  }
344 }
static PetscErrorCode Vec x
unsigned int MonotoneCubicInterpolation::getSampleSize ( )
virtual

This method returns the length of the independent variable vector.

Definition at line 392 of file MonotoneCubicInterpolation.C.

393 {
394  return _x.size();
395 }
Real MonotoneCubicInterpolation::h1 ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 106 of file MonotoneCubicInterpolation.C.

Referenced by p().

107 {
108  Real h = xhi - xlo;
109  Real t = (xhi - x) / h;
110  return phi(t);
111 }
Real phi(const Real &t) const
static PetscErrorCode Vec x
Real MonotoneCubicInterpolation::h1DoublePrime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 123 of file MonotoneCubicInterpolation.C.

Referenced by pDoublePrime().

124 {
125  Real h = xhi - xlo;
126  Real t = (xhi - x) / h;
127  Real tPrime = -1. / h;
128  return phiDoublePrime(t) * tPrime * tPrime;
129 }
static PetscErrorCode Vec x
Real phiDoublePrime(const Real &t) const
Real MonotoneCubicInterpolation::h1Prime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 114 of file MonotoneCubicInterpolation.C.

Referenced by pPrime().

115 {
116  Real h = xhi - xlo;
117  Real t = (xhi - x) / h;
118  Real tPrime = -1. / h;
119  return phiPrime(t) * tPrime;
120 }
Real phiPrime(const Real &t) const
static PetscErrorCode Vec x
Real MonotoneCubicInterpolation::h2 ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 132 of file MonotoneCubicInterpolation.C.

Referenced by p().

133 {
134  Real h = xhi - xlo;
135  Real t = (x - xlo) / h;
136  return phi(t);
137 }
Real phi(const Real &t) const
static PetscErrorCode Vec x
Real MonotoneCubicInterpolation::h2DoublePrime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 149 of file MonotoneCubicInterpolation.C.

Referenced by pDoublePrime().

150 {
151  Real h = xhi - xlo;
152  Real t = (x - xlo) / h;
153  Real tPrime = 1. / h;
154  return phiDoublePrime(t) * tPrime * tPrime;
155 }
static PetscErrorCode Vec x
Real phiDoublePrime(const Real &t) const
Real MonotoneCubicInterpolation::h2Prime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 140 of file MonotoneCubicInterpolation.C.

Referenced by pPrime().

141 {
142  Real h = xhi - xlo;
143  Real t = (x - xlo) / h;
144  Real tPrime = 1. / h;
145  return phiPrime(t) * tPrime;
146 }
Real phiPrime(const Real &t) const
static PetscErrorCode Vec x
Real MonotoneCubicInterpolation::h3 ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 158 of file MonotoneCubicInterpolation.C.

Referenced by p().

159 {
160  Real h = xhi - xlo;
161  Real t = (xhi - x) / h;
162  return -h * psi(t);
163 }
static PetscErrorCode Vec x
Real psi(const Real &t) const
Real MonotoneCubicInterpolation::h3DoublePrime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 175 of file MonotoneCubicInterpolation.C.

Referenced by pDoublePrime().

176 {
177  Real h = xhi - xlo;
178  Real t = (xhi - x) / h;
179  Real tPrime = -1. / h;
180  return psiDoublePrime(t) * tPrime;
181 }
static PetscErrorCode Vec x
Real psiDoublePrime(const Real &t) const
Real MonotoneCubicInterpolation::h3Prime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 166 of file MonotoneCubicInterpolation.C.

Referenced by pPrime().

167 {
168  Real h = xhi - xlo;
169  Real t = (xhi - x) / h;
170  Real tPrime = -1. / h;
171  return -h * psiPrime(t) * tPrime; // psiPrime(t)
172 }
Real psiPrime(const Real &t) const
static PetscErrorCode Vec x
Real MonotoneCubicInterpolation::h4 ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 184 of file MonotoneCubicInterpolation.C.

Referenced by p().

185 {
186  Real h = xhi - xlo;
187  Real t = (x - xlo) / h;
188  return h * psi(t);
189 }
static PetscErrorCode Vec x
Real psi(const Real &t) const
Real MonotoneCubicInterpolation::h4DoublePrime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 201 of file MonotoneCubicInterpolation.C.

Referenced by pDoublePrime().

202 {
203  Real h = xhi - xlo;
204  Real t = (x - xlo) / h;
205  Real tPrime = 1. / h;
206  return psiDoublePrime(t) * tPrime;
207 }
static PetscErrorCode Vec x
Real psiDoublePrime(const Real &t) const
Real MonotoneCubicInterpolation::h4Prime ( const Real &  xhi,
const Real &  xlo,
const Real &  x 
) const
protected

Definition at line 192 of file MonotoneCubicInterpolation.C.

Referenced by pPrime().

193 {
194  Real h = xhi - xlo;
195  Real t = (x - xlo) / h;
196  Real tPrime = 1. / h;
197  return h * psiPrime(t) * tPrime; // psiPrime(t)
198 }
Real psiPrime(const Real &t) const
static PetscErrorCode Vec x
void MonotoneCubicInterpolation::initialize_derivs ( )
protectedvirtual

Definition at line 249 of file MonotoneCubicInterpolation.C.

Referenced by solve().

250 {
251  for (unsigned int i = 1; i < _n_knots - 1; ++i)
252  _yp[i] = (std::pow(_h[i - 1], 2) * _y[i + 1] - std::pow(_h[i], 2) * _y[i - 1] -
253  _y[i] * (_h[i - 1] - _h[i]) * (_h[i - 1] + _h[i])) /
254  (_h[i - 1] * _h[i] * (_h[i - 1] * _h[i]));
255 
256  _yp[0] = (-std::pow(_h[0], 2) * _y[2] - _h[1] * _y[0] * (2 * _h[0] + _h[1]) +
257  _y[1] * std::pow(_h[0] + _h[1], 2)) /
258  (_h[0] * _h[1] * (_h[0] + _h[1]));
259 
260  Real hlast = _h[_n_intervals - 1];
261  Real hsecond = _h[_n_intervals - 2];
262  Real ylast = _y[_n_knots - 1];
263  Real ysecond = _y[_n_knots - 2];
264  Real ythird = _y[_n_knots - 3];
265  _yp[_n_knots - 1] = (hsecond * ylast * (hsecond + 2 * hlast) + std::pow(hlast, 2) * ythird -
266  ysecond * std::pow(hsecond + hlast, 2)) /
267  (hsecond * hlast * (hsecond + hlast));
268 }
void MonotoneCubicInterpolation::modify_derivs ( const Real &  alpha,
const Real &  beta,
const Real &  delta,
Real &  yp_lo,
Real &  yp_hi 
)
protectedvirtual

Definition at line 271 of file MonotoneCubicInterpolation.C.

Referenced by solve().

273 {
274  Real tau = 3. / std::sqrt(std::pow(alpha, 2) + std::pow(beta, 2));
275  Real alpha_star = alpha * tau;
276  Real beta_star = beta * tau;
277  yp_lo = alpha_star * delta;
278  yp_hi = beta_star * delta;
279 }
Real MonotoneCubicInterpolation::p ( const Real &  xhi,
const Real &  xlo,
const Real &  fhi,
const Real &  flo,
const Real &  dhi,
const Real &  dlo,
const Real &  x 
) const
protectedvirtual

Definition at line 210 of file MonotoneCubicInterpolation.C.

Referenced by sample().

217 {
218  return flo * h1(xhi, xlo, x) + fhi * h2(xhi, xlo, x) + dlo * h3(xhi, xlo, x) +
219  dhi * h4(xhi, xlo, x);
220 }
Real h2(const Real &xhi, const Real &xlo, const Real &x) const
Real h3(const Real &xhi, const Real &xlo, const Real &x) const
static PetscErrorCode Vec x
Real h1(const Real &xhi, const Real &xlo, const Real &x) const
Real h4(const Real &xhi, const Real &xlo, const Real &x) const
Real MonotoneCubicInterpolation::pDoublePrime ( const Real &  xhi,
const Real &  xlo,
const Real &  fhi,
const Real &  flo,
const Real &  dhi,
const Real &  dlo,
const Real &  x 
) const
protectedvirtual

Definition at line 236 of file MonotoneCubicInterpolation.C.

Referenced by sample2ndDerivative().

243 {
244  return flo * h1DoublePrime(xhi, xlo, x) + fhi * h2DoublePrime(xhi, xlo, x) +
245  dlo * h3DoublePrime(xhi, xlo, x) + dhi * h4DoublePrime(xhi, xlo, x);
246 }
Real h2DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
static PetscErrorCode Vec x
Real h1DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real h4DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real h3DoublePrime(const Real &xhi, const Real &xlo, const Real &x) const
Real MonotoneCubicInterpolation::phi ( const Real &  t) const
protected

Definition at line 70 of file MonotoneCubicInterpolation.C.

Referenced by h1(), and h2().

71 {
72  return 3. * t * t - 2. * t * t * t;
73 }
Real MonotoneCubicInterpolation::phiDoublePrime ( const Real &  t) const
protected

Definition at line 82 of file MonotoneCubicInterpolation.C.

Referenced by h1DoublePrime(), and h2DoublePrime().

83 {
84  return 6. - 12. * t;
85 }
Real MonotoneCubicInterpolation::phiPrime ( const Real &  t) const
protected

Definition at line 76 of file MonotoneCubicInterpolation.C.

Referenced by h1Prime(), and h2Prime().

77 {
78  return 6. * t - 6. * t * t;
79 }
Real MonotoneCubicInterpolation::pPrime ( const Real &  xhi,
const Real &  xlo,
const Real &  fhi,
const Real &  flo,
const Real &  dhi,
const Real &  dlo,
const Real &  x 
) const
protectedvirtual

Definition at line 223 of file MonotoneCubicInterpolation.C.

Referenced by sampleDerivative().

230 {
231  return flo * h1Prime(xhi, xlo, x) + fhi * h2Prime(xhi, xlo, x) + dlo * h3Prime(xhi, xlo, x) +
232  dhi * h4Prime(xhi, xlo, x);
233 }
static PetscErrorCode Vec x
Real h1Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real h4Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real h3Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real h2Prime(const Real &xhi, const Real &xlo, const Real &x) const
Real MonotoneCubicInterpolation::psi ( const Real &  t) const
protected

Definition at line 88 of file MonotoneCubicInterpolation.C.

Referenced by h3(), and h4().

89 {
90  return t * t * t - t * t;
91 }
Real MonotoneCubicInterpolation::psiDoublePrime ( const Real &  t) const
protected

Definition at line 100 of file MonotoneCubicInterpolation.C.

Referenced by h3DoublePrime(), and h4DoublePrime().

101 {
102  return 6. * t - 2.;
103 }
Real MonotoneCubicInterpolation::psiPrime ( const Real &  t) const
protected

Definition at line 94 of file MonotoneCubicInterpolation.C.

Referenced by h3Prime(), and h4Prime().

95 {
96  return 3. * t * t - 2. * t;
97 }
Real MonotoneCubicInterpolation::sample ( const Real &  x) const
virtual

This function will take an independent variable input and will return the dependent variable based on the generated fit.

Definition at line 347 of file MonotoneCubicInterpolation.C.

Referenced by dumpCSV().

348 {
349  // sanity check (empty MontoneCubicInterpolations are constructable
350  // so we cannot put this into the errorCheck)
351  assert(_x.size() > 0);
352 
353  unsigned int klo, khi;
354  findInterval(x, klo, khi);
355  return p(_x[khi], _x[klo], _y[khi], _y[klo], _yp[khi], _yp[klo], x);
356 }
static PetscErrorCode Vec x
virtual void findInterval(const Real &x, unsigned int &klo, unsigned int &khi) const
virtual Real p(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
Real MonotoneCubicInterpolation::sample2ndDerivative ( const Real &  x) const
virtual

This function will take an independent variable input and will return the second derivative of the dependent variable with respect to the independent variable based on the generated fit.

Note that this can be discontinous at the knots.

Definition at line 367 of file MonotoneCubicInterpolation.C.

Referenced by dumpCSV().

368 {
369  unsigned int klo, khi;
370  findInterval(x, klo, khi);
371  return pDoublePrime(_x[khi], _x[klo], _y[khi], _y[klo], _yp[khi], _yp[klo], x);
372 }
static PetscErrorCode Vec x
virtual void findInterval(const Real &x, unsigned int &klo, unsigned int &khi) const
virtual Real pDoublePrime(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
Real MonotoneCubicInterpolation::sampleDerivative ( const Real &  x) const
virtual

This function will take an independent variable input and will return the derivative of the dependent variable with respect to the independent variable based on the generated fit.

Definition at line 359 of file MonotoneCubicInterpolation.C.

Referenced by dumpCSV().

360 {
361  unsigned int klo, khi;
362  findInterval(x, klo, khi);
363  return pPrime(_x[khi], _x[klo], _y[khi], _y[klo], _yp[khi], _yp[klo], x);
364 }
virtual Real pPrime(const Real &xhi, const Real &xlo, const Real &fhi, const Real &flo, const Real &dhi, const Real &dlo, const Real &x) const
static PetscErrorCode Vec x
virtual void findInterval(const Real &x, unsigned int &klo, unsigned int &khi) const
void MonotoneCubicInterpolation::setData ( const std::vector< Real > &  x,
const std::vector< Real > &  y 
)
virtual

Method generally used when MonotoneCubicInterpolation object was created using the empty constructor.

Takes two vectors of points for which to apply the fit. One should be of the independent variable while the other should be of the dependent variable. These values should have a one-to-one correspondence, e.g. the vectors must be of the same size.

Definition at line 35 of file MonotoneCubicInterpolation.C.

36 {
37  _x = x;
38  _y = y;
39  errorCheck();
40  solve();
41 }
static PetscErrorCode Vec x
Real MonotoneCubicInterpolation::sign ( const Real &  x) const
protected

Definition at line 59 of file MonotoneCubicInterpolation.C.

Referenced by solve().

60 {
61  if (x < 0)
62  return -1;
63  else if (x > 0)
64  return 1;
65  else
66  return 0;
67 }
static PetscErrorCode Vec x
void MonotoneCubicInterpolation::solve ( )
protectedvirtual

Definition at line 282 of file MonotoneCubicInterpolation.C.

Referenced by MonotoneCubicInterpolation(), and setData().

283 {
284  _n_knots = _x.size(), _n_intervals = _x.size() - 1, _internal_knots = _x.size() - 2;
285  _h.resize(_n_intervals);
286  _yp.resize(_n_knots);
287  _delta.resize(_n_intervals);
288  _alpha.resize(_n_intervals);
289  _beta.resize(_n_intervals);
290 
291  for (unsigned int i = 0; i < _n_intervals; ++i)
292  _h[i] = _x[i + 1] - _x[i];
293 
295  for (unsigned int i = 0; i < _n_intervals; ++i)
296  _delta[i] = (_y[i + 1] - _y[i]) / _h[i];
297  if (sign(_delta[0]) != sign(_yp[0]))
298  _yp[0] = 0;
299  if (sign(_delta[_n_intervals - 1]) != sign(_yp[_n_knots - 1]))
300  _yp[_n_knots - 1] = 0;
301  for (unsigned int i = 0; i < _internal_knots; ++i)
302  if (sign(_delta[i + 1]) == 0 || sign(_delta[i]) == 0 || sign(_delta[i + 1]) != sign(_delta[i]))
303  _yp[1 + i] = 0;
304 
305  for (unsigned int i = 0; i < _n_intervals; ++i)
306  {
307  // Test for zero slope
308  if (_yp[i] == 0)
309  _alpha[i] = 0;
310  else if (_delta[i] == 0)
311  _alpha[i] = 4;
312  else
313  _alpha[i] = _yp[i] / _delta[i];
314 
315  // Test for zero slope
316  if (_yp[i + 1] == 0)
317  _beta[i] = 0;
318  else if (_delta[i] == 0)
319  _beta[i] = 4;
320  else
321  _beta[i] = _yp[i + 1] / _delta[i];
322 
323  // check if outside region of monotonicity
324  if (std::pow(_alpha[i], 2) + std::pow(_beta[i], 2) > 9.)
325  modify_derivs(_alpha[i], _beta[i], _delta[i], _yp[i], _yp[i + 1]);
326  }
327 }
virtual void modify_derivs(const Real &alpha, const Real &beta, const Real &delta, Real &yp_lo, Real &yp_hi)
Real sign(const Real &x) const

Member Data Documentation

std::vector<Real> MonotoneCubicInterpolation::_alpha
protected

Definition at line 152 of file MonotoneCubicInterpolation.h.

Referenced by solve().

std::vector<Real> MonotoneCubicInterpolation::_beta
protected

Definition at line 153 of file MonotoneCubicInterpolation.h.

Referenced by solve().

std::vector<Real> MonotoneCubicInterpolation::_delta
protected

Definition at line 151 of file MonotoneCubicInterpolation.h.

Referenced by solve().

std::vector<Real> MonotoneCubicInterpolation::_h
protected

Definition at line 149 of file MonotoneCubicInterpolation.h.

Referenced by initialize_derivs(), and solve().

unsigned int MonotoneCubicInterpolation::_internal_knots
protected

Definition at line 157 of file MonotoneCubicInterpolation.h.

Referenced by solve().

unsigned int MonotoneCubicInterpolation::_n_intervals
protected

Definition at line 156 of file MonotoneCubicInterpolation.h.

Referenced by initialize_derivs(), and solve().

unsigned int MonotoneCubicInterpolation::_n_knots
protected

Definition at line 155 of file MonotoneCubicInterpolation.h.

Referenced by findInterval(), initialize_derivs(), and solve().

std::vector<Real> MonotoneCubicInterpolation::_x
protected
std::vector<Real> MonotoneCubicInterpolation::_y
protected
std::vector<Real> MonotoneCubicInterpolation::_yp
protected

The documentation for this class was generated from the following files: