1 #include <Eigen/Dense> 2 #include <iostream> 3 4 using namespace Eigen; 5 using namespace std; 6 main()7int main() 8 { 9 MatrixXf m(2,2); 10 m << 1,-2, 11 -3,4; 12 13 cout << "1-norm(m) = " << m.cwiseAbs().colwise().sum().maxCoeff() 14 << " == " << m.colwise().lpNorm<1>().maxCoeff() << endl; 15 16 cout << "infty-norm(m) = " << m.cwiseAbs().rowwise().sum().maxCoeff() 17 << " == " << m.rowwise().lpNorm<1>().maxCoeff() << endl; 18 } 19