Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <Eigen/Dense>
3 
4 using namespace std;
5 using namespace Eigen;
6 int 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 }
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
main
int main()
Definition: Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp:6
std
Definition: BFloat16.h:88
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:07:51