I am having trouble converting type vector< vector > to an array.So far, I've tried to do the following (with help from /u/ Robert Crovella)
pos_x_h=(double *)malloc(N*sizeof(double));
pos_y_h=(double *)malloc(N*sizeof(double));
for (int i = 0; i<N; i++){
vector<double> temp = r[i];
pos_x_h[i] = temp[i][0];
pos_y_h[i] = temp[i][1];
}
Here, r is the position vector with N elements each having x and y components. I also tried doing
double arr[N];
std::copy(r.begin(), r.end(), arr);
Both attempts didn't work, and I'm not sure why. You can see the code here.