Can someone be able to tell me how to convert vector to an array? I have a function that returns a vector of double type with typical like this
std::vector<double> x_vec = LinspaceArray_DK2(0, 5.0, 0.01);
std::vector<double> y_vec = Calculate_y_vec(x_vec);
However, following GSL (GNU scientific lib) function is expecting an array as an input
gsl_spline_init (spline, x_array, y_array, x_vec.length);
Here, x_array, y_array are arrays corresponding to vectors x_vec and y_vec.
I tried following solution here (How to convert vector to array in C++) which suggest conversion like this:
std::vector<double> v;
double* a = &v[0];
But, this type of conversion did not help with gsl_spline_init which expected arrays as inputs.
Updated:
I tried to call like this:
// Convert all vector to an array
double* x_input_Array = &x_input[0];
double* y_input_Array = &y_input[0];
and then call:
gsl_spline_init (spline, *x_input_Array, *y_input_Array, iNoOfPtsIni);
I am getting this error: error C2664: 'gsl_spline_init' : cannot convert parameter 2 from 'double' to 'const double []'
Thanks, DK