c++ - Breaking out a vector from a 2D vector -


i have 2d vector contains 138 vectors. need break out each of 138 vectors in order calculate dot product. have working dot product function, i'm having hard time breaking out individual vectors initial 2d vectors. here's have:

for (unsigned = 0u; != templatevector.size(); ++i) {     for(vector<double> vec : templatevector){        // cout << face.quicksort(vec, 0.0, 9.0);      cout << "\nscalar_product: index[" << <<"] " << face.scalar_product(vec, queryvector);     }      std::cout << "\n";  } 

it ends printing dot product of each vector (index i) 138 times. templatevector vector contains 138 "vec" vectors, each of has 5,632 doubles. queryvector contains 5,632 doubles well.

thanks in advance help.

your outter loop unnecessary (and reason why see 138 times output each vector), , inner for-range loop unnecessarily copies vectors.

simply :

for(auto& vec : templatevector){  cout << "\nscalar_product: index[" << <<"] " << face.scalar_product(vec, queryvector); } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -