source: pacpussensors/trunk/Vislab/lib3dv-1.2.0/lib3dv/eigen/doc/snippets/TopicAliasing_cwise.cpp

Last change on this file was 136, checked in by ldecherf, 8 years ago

Doc

File size: 591 bytes
Line 
1MatrixXf mat(2,2);
2mat << 1, 2, 4, 7;
3cout << "Here is the matrix mat:\n" << mat << endl << endl;
4
5mat = 2 * mat;
6cout << "After 'mat = 2 * mat', mat = \n" << mat << endl << endl;
7
8
9mat = mat - MatrixXf::Identity(2,2);
10cout << "After the subtraction, it becomes\n" << mat << endl << endl;
11
12
13ArrayXXf arr = mat;
14arr = arr.square();
15cout << "After squaring, it becomes\n" << arr << endl << endl;
16
17// Combining all operations in one statement:
18mat << 1, 2, 4, 7;
19mat = (2 * mat - MatrixXf::Identity(2,2)).array().square();
20cout << "Doing everything at once yields\n" << mat << endl << endl;
Note: See TracBrowser for help on using the repository browser.