I have started with an example of gsl fitting examples and tried to change the arrays to vectors. but when I compile my code, it leads to an error of this, which I dont understand and dont know what is wrong with my code, i appreciate any comment in advance:
example1.cpp:19:73: error: cannot convert ‘std::vector’ to ‘const double*’ for argument ‘1’ to ‘int gsl_fit_linear(const double*, size_t, const double*, size_t, size_t, double*, double*, double*, double*, double*, double*)’ gsl_fit_linear (x, 1, y, 1, n, &c0, &c1, &cov00, &cov01, &cov11, &sumsq);
and this is the code:
#include <iostream>
#include <vector>
#include <gsl/gsl_fit.h>
using namespace std;
int main (void)
{
int n = 5;
vector <double> x(5,0);
vector <double> y(5,0);
for(int i=0 ; i< 5; i++)
x[i] = i*3.2;
for(int i=0 ; i< 5; i++)
x[i] = i*2-11.6;
double c0, c1, cov00, cov01, cov11, sumsq;
gsl_fit_linear (x, 1, y, 1, n, &c0, &c1, &cov00, &cov01, &cov11, &sumsq);
return 0;
}