//Compilar con g++ -I. -I./templates neville.cpp
#include <cmath>
#include <iostream>
#include "algebralineal.h"
#include<iomanip>
#include "interpolacion.h"
typedef double Real;
using namespace std;
using namespace CALNUM;


template <class T>  T fun( T x, int i){
if (i==1)
  return sin(x);
else if(i==2) 
  return tan(x);
else if (i=3)
  return T(1)/sqrt(1+x*x);  
}

int main()
{ 
cout<< "Entrar numero de puntos"<< endl;
int n;
cin >> n;
Vector<Real> x(n), y(n);
cout<<"Entrar limite inferior"<<endl;
Real x0, x1;
cin>> x0;
cout<<"Entrar limite superior"<<endl;
cin>>x1;
Real delta= (x1-x0)/(n-1);

cout<< "Entrar funcion" << endl<<
"1. sin(x)"<<endl<<
"2. tan(x)" <<endl <<
"3. runge(x)" << endl;

// Entrar tipo de funcion
int ifun;
cin >>ifun;

for (int i=1; i<=n;i++) {
x(i) = x0 + i*delta;
y(i)= fun(x(i), ifun);
}
Real xint;
cout<<" Entrar x"<<endl;
cin>> xint;
Real yint = Neville<Real>(x,y,xint);
cout<<setprecision(10)<<" x "<< "y-interp   " <<  "   f(x) "<< endl;
cout<<xint<< "  "<<yint<<"    "<<fun(xint,ifun)<<endl;
return 0;
}

