aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2011-02-12 23:17:31 +0000
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2011-02-12 23:17:31 +0000
commit8bca23bbec33a5ef755da641116418f4dc90e0da (patch)
treec7dbb07a3e719c2956fce6bc13b70e62c1ded008 /doc
parent1a6597b8e44e2f828e6da017d1aef1e1be3d5f81 (diff)
Mention comma initializer can be used to concatenate vectors
(inspired by a question on IRC)
Diffstat (limited to 'doc')
-rw-r--r--doc/C05_TutorialAdvancedInitialization.dox24
-rw-r--r--doc/snippets/Tutorial_AdvancedInitialization_Join.cpp11
2 files changed, 29 insertions, 6 deletions
diff --git a/doc/C05_TutorialAdvancedInitialization.dox b/doc/C05_TutorialAdvancedInitialization.dox
index b6293bef2..4f27f1e4d 100644
--- a/doc/C05_TutorialAdvancedInitialization.dox
+++ b/doc/C05_TutorialAdvancedInitialization.dox
@@ -32,20 +32,20 @@ or too many coefficients, Eigen will complain.
\verbinclude Tutorial_commainit_01.out
</td></tr></table>
-The comma initializer can also be used to fill block expressions such as <tt>m.row(i)</tt>. Here is a more
-complicated way to get the same result as above:
+Moreover, the elements of the initialization list may themselves be vectors or matrices. A common use is
+to join vectors or matrices together. For example, here is how to join two row vectors together. Remember
+that you have to set the size before you can use the comma initializer.
<table class="example">
<tr><th>Example:</th><th>Output:</th></tr>
<tr><td>
-\include Tutorial_commainit_01b.cpp
+\include Tutorial_AdvancedInitialization_Join.cpp
</td>
<td>
-\verbinclude Tutorial_commainit_01b.out
+\verbinclude Tutorial_AdvancedInitialization_Join.out
</td></tr></table>
-Moreover, the elements of the initialization list may themselves be matrices. Thus, we can use them to
-initialize matrices with a block structure.
+We can use the same technique to initialize matrices with a block structure.
<table class="example">
<tr><th>Example:</th><th>Output:</th></tr>
@@ -56,6 +56,18 @@ initialize matrices with a block structure.
\verbinclude Tutorial_AdvancedInitialization_Block.out
</td></tr></table>
+The comma initializer can also be used to fill block expressions such as <tt>m.row(i)</tt>. Here is a more
+complicated way to get the same result as in the first example above:
+
+<table class="example">
+<tr><th>Example:</th><th>Output:</th></tr>
+<tr><td>
+\include Tutorial_commainit_01b.cpp
+</td>
+<td>
+\verbinclude Tutorial_commainit_01b.out
+</td></tr></table>
+
\section TutorialAdvancedInitializationSpecialMatrices Special matrices and arrays
diff --git a/doc/snippets/Tutorial_AdvancedInitialization_Join.cpp b/doc/snippets/Tutorial_AdvancedInitialization_Join.cpp
new file mode 100644
index 000000000..84e8715cb
--- /dev/null
+++ b/doc/snippets/Tutorial_AdvancedInitialization_Join.cpp
@@ -0,0 +1,11 @@
+RowVectorXd vec1(3);
+vec1 << 1, 2, 3;
+std::cout << "vec1 = " << vec1 << std::endl;
+
+RowVectorXd vec2(4);
+vec2 << 1, 4, 9, 16;;
+std::cout << "vec2 = " << vec2 << std::endl;
+
+RowVectorXd joined(7);
+joined << vec1, vec2;
+std::cout << "joined = " << joined << std::endl;