Line | |
---|
1 | #include <Eigen/Dense>
|
---|
2 | #include <iostream>
|
---|
3 |
|
---|
4 | using namespace Eigen;
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 | int main(int, char**)
|
---|
8 | {
|
---|
9 | cout.precision(3);
|
---|
10 | Matrix2f M = Matrix2f::Random();
|
---|
11 | Matrix2f m;
|
---|
12 | m = M;
|
---|
13 | cout << "Here is the matrix m:" << endl << m << endl;
|
---|
14 | cout << "Now we want to copy a column into a row." << endl;
|
---|
15 | cout << "If we do m.col(1) = m.row(0), then m becomes:" << endl;
|
---|
16 | m.col(1) = m.row(0);
|
---|
17 | cout << m << endl << "which is wrong!" << endl;
|
---|
18 | cout << "Now let us instead do m.col(1) = m.row(0).eval(). Then m becomes" << endl;
|
---|
19 | m = M;
|
---|
20 | m.col(1) = m.row(0).eval();
|
---|
21 | cout << m << endl << "which is right." << endl;
|
---|
22 |
|
---|
23 | return 0;
|
---|
24 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.