xref: /aosp_15_r20/external/eigen/doc/snippets/TopicAliasing_mult2.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li MatrixXf matA(2,2), matB(2,2);
2*bf2c3715SXin Li matA << 2, 0,  0, 2;
3*bf2c3715SXin Li 
4*bf2c3715SXin Li // Simple but not quite as efficient
5*bf2c3715SXin Li matB = matA * matA;
6*bf2c3715SXin Li cout << matB << endl << endl;
7*bf2c3715SXin Li 
8*bf2c3715SXin Li // More complicated but also more efficient
9*bf2c3715SXin Li matB.noalias() = matA * matA;
10*bf2c3715SXin Li cout << matB;
11