i have a 3d stl vector,
vector<vector<vector<double> > > mdata;
i also have a function
myfun(const double ya[]);
to be more precise, it’s a function from the GNU Scientific Library,
gsl_spline_init(gsl_spline * spline, const double xa[], const double ya[], size_t size);
but this is not related to my problem.
so now i want to pass the ‘last’ dimension of data to myfun. i’ve been trying this:
for (int s = 0; s < msize; s++) {
accelerators = new gsl_interp_accel*[msize];
splines = new gsl_spline*[msize];
for (int i = 0; i < msize; i++) {
accelerators[i] = gsl_interp_accel_alloc();
splines[i] = gsl_spline_alloc(gsl_interp_cspline_periodic, msize+1);
gsl_spline_init(splines[i], &(*mgrid.begin()), &(*mdata[s][i].begin()), msize+1);
}
}
But the compiler (g++, 64bit, Ubuntu), complains:
In member function
‘std::vector<std::vector<std::vector<double,’:
std::allocator<double> >,
std::allocator<std::vector<double,
std::allocator<double> > > >,
std::allocator<std::vector<std::vector<double,
std::allocator<double> >,
std::allocator<std::vector<double,
std::allocator<double> > > > > >
SimpleAmfCalculator::interp_m(int)
Calculator.cpp:100: error: cannot
convert ‘std::vector<double,’ to ‘
std::allocator<double> >*const’ for argument ‘3’ to ‘
double*int’ make:
gsl_spline_init(gsl_spline*, const
double*, const double*, size_t)
*** [Calculator.o] Error 1
Any help is greatly apprecitated!
So, the following seems to work for me: