/**
file: interpol.h
date: 2018-03-28
author: Michal Krelina
purpose:
  method for interpolation of data from grid

  Please cite the following paper if you use the code with vector mesons wave function of total cross section grids: 
  J.Cepila, M.Krelina, J.Nemchik, R.Pasechnik, Phys.Rev.DXX:XXXX,2018 [arXiv:XXXX.XXXX].
**/


//...basic system include....
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <cstdlib>

#ifndef _interpol_H_
#define _interpol_H_

namespace interpol {

  struct data {
    double ** y;        // y values
    double * x;         // x values
    double ** xLimits;  // limits of each x values
    int * xNum;         // number of values of x values
    int isData;         // flag is data loaded
    int xDim;           // number of x values
    int yDim;           // number of y values
    int N;              // number of lines
    std::string file;   // name of file
  };
  
  // load data from grid file
  void iniFile(data & s, std::string file, int print = 1);

  // return interpolated value
  double get(data & s, double* x);
  
  // delete dynamic arrays
  void del(data & s);

}

#endif