How to improve std::vector time? Hi i am making a software for multivariable fuzzy k means cluster. It work over big matrix´s 50.000 observations by 10 variables. The matrix not need to grow up o shrink or bounds check. Only make a resize to the needed size, load items and then make a lot of access.
First use:
`std::vector< std::vector<double> > matrix(NumClusters, std::vector<double>(NumObs,0.0));`
To get element do: double A=matrix[i][j]; But the procces time was of 20 minutes.
Then make:
std::vector<double> U(NumClusters *NumObs,0.0);
To get element do: double A=U[i*NumObs+j]; and the time was better.
Now want to make a question: Which will be more faster to get access:
iterator+int
std::vector<double>::const_iterator Uit = U.begin();
double A= *(Uit+index)
pointer[int]
std::vector<double>::const_pointer Upt = U.data();
double A= Upt[index];
Or normal index access[int]
double A= U[index];
Greetings