xref: /aosp_15_r20/external/eigen/doc/snippets/MatrixBase_colwise_iterator_cxx11.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1 Matrix3i m = Matrix3i::Random();
2 cout << "Here is the initial matrix m:" << endl << m << endl;
3 int i = -1;
4 for(auto c: m.colwise()) {
5   c *= i;
6   ++i;
7 }
8 cout << "Here is the matrix m after the for-range-loop:" << endl << m << endl;
9 auto cols = m.colwise();
10 auto it = std::find_if(cols.cbegin(), cols.cend(),
__anon23501d5b0102(Matrix3i::ConstColXpr x) 11                        [](Matrix3i::ConstColXpr x) { return x.squaredNorm() == 0; });
12 cout << "The first empty column is: " << distance(cols.cbegin(),it) << endl;
13