/*********************************************************************
 * File  : interp.h
 * Author: Sylvain BARTHELEMY
 *         http://www.sylbarth.com
 * Date  : 1999-11
 *********************************************************************/


#ifndef _ENL_INTERP_H_
#define _ENL_INTERP_H_

// --- cubic splines end condition
// iend = 1 : linear end condition, s(1)=s(n)=0
// iend = 2 : parabolic ends: s(1)=s(2),s(n-1)=s(n)
// iend = 3 : cubic end condition
// iend = 4 : first derivative is known at x(1)
//            and stored in a[1] and the first
//            derivative is know at x(n) and stored
//            in a[2].
const int ENL_CSPLINE_LINEAR    = 1;
const int ENL_CSPLINE_PARABOLIC = 2;
const int ENL_CSPLINE_CUBIC     = 3;
const int ENL_CSPLINE_FDEV      = 4;

// --- interpolations class
class enl_interp {

  // --- cubic splines end condition
  int     m_iend;

  // --- divided differences polynome coef
  double* m_dd;

  // --- cspline polynome coef
  double* m_a;
  double* m_b;
  double* m_c;

  // --- orig data
  double* m_x;
  double* m_y;
  int     m_n;

  // --- booleans
  bool m_cspline;
  bool m_divdiff;

  void divdiff_coef();
  void cspline_coef();

public:
  enl_interp(const double* x, const double* y, const int& n);
  ~enl_interp();

  double lagrange ( const double& u );
  double divdiff  ( const double& u );
  double cspline  ( const double& u, int* store);


};

#endif
