aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/snippets/Triangular_solve.cpp
blob: 5484424673261816628d73454c225092074eed69 (plain)
1
2
3
4
5
6
7
8
9
10
11
Matrix3d m = Matrix3d::Zero();
m.triangularView<Eigen::Upper>().setOnes();
cout << "Here is the matrix m:\n" << m << endl;
Matrix3d n = Matrix3d::Ones();
n.triangularView<Eigen::Lower>() *= 2;
cout << "Here is the matrix n:\n" << n << endl;
cout << "And now here is m.inverse()*n, taking advantage of the fact that"
        " m is upper-triangular:\n"
     << m.triangularView<Eigen::Upper>().solve(n) << endl;
cout << "And this is n*m.inverse():\n"
     << m.triangularView<Eigen::Upper>().solve<Eigen::OnTheRight>(n);