dimanche 12 avril 2020

vector(vector

i try to generate a dynamic matrix with "max_step" rows and "degree" collums. But the indicies of the vector elements are not 0,1,2,3....max_step. I always get 0,2,4,...max_step. If i want to (logical) accsess line 3, I'll recive (of course) an error (free() invalid pointer) or similar.

vector<double> qd_algorithm(const std::function<vector<double>()>& poly, const unsigned int max_steps, const unsigned int degree)
{
   vector<vector<double>> e(max_steps, vector<double>(degree+1));

   for (unsigned int i=0;i<max_steps;i++)
   {
       e[i][0]=0;
       e[i][degree+1]=0;
   }
   //stop point debugging
   return poly(); //just for trying

}

What am I doing wrong ?

Aucun commentaire:

Enregistrer un commentaire