Further to my earlier question I would like to find the minimum element of each row of a two dimensional matrix in C++. The matrix is constructed out of two vectors. Below is my attempt, building on the logo of a single case. Here i is the index of the rows and I use j as the index of the columns.
std::vector<T> vecRow;
std::vector<vecRow> vecCol;
auto minIt =std:min_element(vecCol.at(i).vecRow.begin(), vecCol.at(i).vecRow.end());
auto minEl =*minIt;
auto index = std::distance(vecCol.at(i).vecRow.begin(), std::min_element(vecCol.at(i).vecRow.begin(), vecCol.at(i).vecRow.end());
Aucun commentaire:
Enregistrer un commentaire