aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/examples/Tutorial_simple_example_dynamic_size.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-08-24 19:14:20 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-08-24 19:14:20 +0000
commit854d6e8458a379e1583f6e2c835263ca5bdb19a5 (patch)
tree0f17fe963f333f752d77af7edd3fb21aaacc108e /doc/examples/Tutorial_simple_example_dynamic_size.cpp
parent251ecc0ab9ee7bf923c5212ab93bdf02dc8156d7 (diff)
Documentation: fill the placeholders, add a custom CSS file,
add a reference to the tutorial in the main page.
Diffstat (limited to 'doc/examples/Tutorial_simple_example_dynamic_size.cpp')
-rw-r--r--doc/examples/Tutorial_simple_example_dynamic_size.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/examples/Tutorial_simple_example_dynamic_size.cpp b/doc/examples/Tutorial_simple_example_dynamic_size.cpp
new file mode 100644
index 000000000..93486e6a0
--- /dev/null
+++ b/doc/examples/Tutorial_simple_example_dynamic_size.cpp
@@ -0,0 +1,22 @@
+#include <Eigen/Core>
+
+// import most common Eigen's types
+USING_PART_OF_NAMESPACE_EIGEN
+
+int main(int argc, char *argv[])
+{
+ for (int size=1; size<=4; ++size)
+ {
+ MatrixXi m(size,size+1); // creates a size x (size+1) matrix of int
+ for (int j=0; j<m.cols(); ++j) // loop over the columns
+ for (int i=0; i<m.rows(); ++i) // loop over the rows
+ m(i,j) = i+j*m.rows(); // to access matrix elements use operator (int,int)
+ std::cout << m << "\n\n";
+ }
+
+ VectorXf v4(4);
+ // to access vector elements
+ // you can use either operator () or operator []
+ v4[0] = 1; v4[1] = 2; v4(2) = 3; v4(3) = 4;
+ std::cout << "\nv4:\n" << v4 << std::endl;
+}