Benoit Jacob | 486fdb2 | 2008-05-29 03:12:30 +0000 | [diff] [blame] | 1 | Matrix2d m; m << 1,2,3,4; |
| 2 | Matrix2d n; |
| 3 | n = (m*m).lazy(); // if we did "n = m*m;" then m*m would first be evaluated into |
| 4 | // a temporary, because the Product expression has the EvalBeforeAssigningBit. |
| 5 | // This temporary would then be copied into n. Introducing this temporary is |
| 6 | // useless here and wastes time. Doing "n = (m*m).lazy();" evaluates m*m directly |
| 7 | // into n, which is faster. But, beware! This is only correct because m and n |
| 8 | // are two distinct matrices. Doing "m = (m*m).lazy();" would not produce the |
| 9 | // expected result. |
| 10 | cout << n << endl; |