Simplify API by removing allCols/allRows and reusing rowwise/colwise to define iterators over rows/columns

This commit is contained in:
Gael Guennebaud
2018-10-05 23:11:21 +02:00
parent 91613bf2c2
commit d92f004ab7
6 changed files with 50 additions and 51 deletions

View File

@@ -0,0 +1,12 @@
Matrix3i m = Matrix3i::Random();
cout << "Here is the initial matrix m:" << endl << m << endl;
int i = -1;
for(auto c: m.colwise()) {
c *= i;
++i;
}
cout << "Here is the matrix m after the for-range-loop:" << endl << m << endl;
auto cols = m.colwise();
auto it = std::find_if(cols.cbegin(), cols.cend(),
[](Matrix3i::ConstColXpr x) { return x.squaredNorm() == 0; });
cout << "The first empty column is: " << distance(cols.cbegin(),it) << endl;