diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-10-05 23:11:21 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-10-05 23:11:21 +0200 |
commit | d92f004ab76cdf961b9279e228d9eb7349a4d8db (patch) | |
tree | 0e49c01b0491ea8e69886d001966ab9bbea3ed01 /doc/snippets | |
parent | 91613bf2c2132fc4b45182146f9367398b6167f0 (diff) |
Simplify API by removing allCols/allRows and reusing rowwise/colwise to define iterators over rows/columns
Diffstat (limited to 'doc/snippets')
-rw-r--r-- | doc/snippets/MatrixBase_colwise_iterator_cxx11.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/snippets/MatrixBase_colwise_iterator_cxx11.cpp b/doc/snippets/MatrixBase_colwise_iterator_cxx11.cpp new file mode 100644 index 000000000..88a9cd357 --- /dev/null +++ b/doc/snippets/MatrixBase_colwise_iterator_cxx11.cpp @@ -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;
\ No newline at end of file |