diff options
author | 2009-06-24 22:07:03 +0200 | |
---|---|---|
committer | 2009-06-24 22:07:03 +0200 | |
commit | 03ad303d1417e53b8bcec8dd8d8e404cd4e13af4 (patch) | |
tree | 92cc1f23881836e6beda8d000fa98c822deb7af1 /doc/snippets | |
parent | 96dca681b04c9bd10081ef46453049cda1ee74df (diff) |
* add resize(int, NoChange) and resize(NoChange, int)
* add missing assert in resize(int)
* add examples for all resize variants
* expand docs (part of which is from Tim Hutt's e-mail)
Diffstat (limited to 'doc/snippets')
-rw-r--r-- | doc/snippets/Matrix_resize_NoChange_int.cpp | 3 | ||||
-rw-r--r-- | doc/snippets/Matrix_resize_int.cpp | 6 | ||||
-rw-r--r-- | doc/snippets/Matrix_resize_int_NoChange.cpp | 3 | ||||
-rw-r--r-- | doc/snippets/Matrix_resize_int_int.cpp | 9 |
4 files changed, 21 insertions, 0 deletions
diff --git a/doc/snippets/Matrix_resize_NoChange_int.cpp b/doc/snippets/Matrix_resize_NoChange_int.cpp new file mode 100644 index 000000000..acdf18c46 --- /dev/null +++ b/doc/snippets/Matrix_resize_NoChange_int.cpp @@ -0,0 +1,3 @@ +MatrixXd m(3,4); +m.resize(NoChange, 5); +cout << "m: " << m.rows() << " rows, " << m.cols() << " cols" << endl; diff --git a/doc/snippets/Matrix_resize_int.cpp b/doc/snippets/Matrix_resize_int.cpp new file mode 100644 index 000000000..044c78989 --- /dev/null +++ b/doc/snippets/Matrix_resize_int.cpp @@ -0,0 +1,6 @@ +VectorXd v(10); +v.resize(3); +RowVector3d w; +w.resize(3); // this is legal, but has no effect +cout << "v: " << v.rows() << " rows, " << v.cols() << " cols" << endl; +cout << "w: " << w.rows() << " rows, " << w.cols() << " cols" << endl; diff --git a/doc/snippets/Matrix_resize_int_NoChange.cpp b/doc/snippets/Matrix_resize_int_NoChange.cpp new file mode 100644 index 000000000..5c37c9067 --- /dev/null +++ b/doc/snippets/Matrix_resize_int_NoChange.cpp @@ -0,0 +1,3 @@ +MatrixXd m(3,4); +m.resize(5, NoChange); +cout << "m: " << m.rows() << " rows, " << m.cols() << " cols" << endl; diff --git a/doc/snippets/Matrix_resize_int_int.cpp b/doc/snippets/Matrix_resize_int_int.cpp new file mode 100644 index 000000000..bfd474159 --- /dev/null +++ b/doc/snippets/Matrix_resize_int_int.cpp @@ -0,0 +1,9 @@ +MatrixXd m(2,3); +m << 1,2,3,4,5,6; +cout << "here's the 2x3 matrix m:" << endl << m << endl; +cout << "let's resize m to 3x2. This is a conservative resizing because 2*3==3*2." << endl; +m.resize(3,2); +cout << "here's the 3x2 matrix m:" << endl << m << endl; +cout << "now let's resize m to size 2x2. This is NOT a conservative resizing, so it becomes uninitialized:" << endl; +m.resize(2,2); +cout << m << endl; |