Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <Eigen/Dense>
3 
4 int main()
5 {
6  Eigen::MatrixXf mat(2,4);
7  mat << 1, 2, 6, 9,
8  3, 1, 7, 2;
9 
10  Eigen::Index maxIndex;
11  float maxNorm = mat.colwise().sum().maxCoeff(&maxIndex);
12 
13  std::cout << "Maximum sum at position " << maxIndex << std::endl;
14 
15  std::cout << "The corresponding vector is: " << std::endl;
16  std::cout << mat.col( maxIndex ) << std::endl;
17  std::cout << "And its sum is is: " << maxNorm << std::endl;
18 }
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82