1#include <iostream> 2#include <Eigen/Dense> 3 4using namespace std; 5using namespace Eigen; 6int main() 7{ 8 MatrixXf mat(2,4); 9 mat << 1, 2, 6, 9, 10 3, 1, 7, 2; 11 12 MatrixXf::Index maxIndex; 13 float maxNorm = mat.colwise().sum().maxCoeff(&maxIndex); 14 15 std::cout << "Maximum sum at position " << maxIndex << std::endl; 16 17 std::cout << "The corresponding vector is: " << std::endl; 18 std::cout << mat.col( maxIndex ) << std::endl; 19 std::cout << "And its sum is is: " << maxNorm << std::endl; 20} 21