aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/examples/Tutorial_simple_example_dynamic_size.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-09-15 15:45:41 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-09-15 15:45:41 +0000
commit247f2b0ffa734d2133db9bb81a48cb4b5620d145 (patch)
tree44610107cad4e0508177cad78d490c5dd6f427d2 /doc/examples/Tutorial_simple_example_dynamic_size.cpp
parent0940ad7127474dc0b6e5e271502988cb7141843a (diff)
* block() for vectors ---> segment()
* documentation improvements, especially in quickstart guide
Diffstat (limited to 'doc/examples/Tutorial_simple_example_dynamic_size.cpp')
-rw-r--r--doc/examples/Tutorial_simple_example_dynamic_size.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/doc/examples/Tutorial_simple_example_dynamic_size.cpp b/doc/examples/Tutorial_simple_example_dynamic_size.cpp
index 5aecc8746..be5e88d29 100644
--- a/doc/examples/Tutorial_simple_example_dynamic_size.cpp
+++ b/doc/examples/Tutorial_simple_example_dynamic_size.cpp
@@ -1,23 +1,22 @@
#include <Eigen/Core>
-// import most common Eigen's types
+// import most common Eigen types
USING_PART_OF_NAMESPACE_EIGEN
int main(int, char *[])
{
for (int size=1; size<=4; ++size)
{
- MatrixXi m(size,size+1); // 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)
+ MatrixXi m(size,size+1); // a (size)x(size+1)-matrix of int's
+ for (int j=0; j<m.cols(); ++j) // loop over columns
+ for (int i=0; i<m.rows(); ++i) // loop over rows
+ m(i,j) = i+j*m.rows(); // to access matrix coefficients,
+ // 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;
+ VectorXf v(4); // a vector of 4 float's
+ // to access vector coefficients, use either operator () or operator []
+ v[0] = 1; v[1] = 2; v(2) = 3; v(3) = 4;
+ std::cout << "\nv:\n" << v << std::endl;
}