Tutorial_ReductionsVisitorsBroadcasting_maxnorm.cpp File Reference
#include <iostream>
#include <Eigen/Dense>

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
4  {
5  Eigen::MatrixXf mat(2, 4);
6  mat << 1, 2, 6, 9, 3, 1, 7, 2;
7 
8  Eigen::Index maxIndex;
9  float maxNorm = mat.colwise().sum().maxCoeff(&maxIndex);
10 
11  std::cout << "Maximum sum at position " << maxIndex << std::endl;
12 
13  std::cout << "The corresponding vector is: " << std::endl;
14  std::cout << mat.col(maxIndex) << std::endl;
15  std::cout << "And its sum is is: " << maxNorm << std::endl;
16 }
Eigen::SparseMatrix< double > mat
Definition: EigenUnitTest.cpp:10
Scalar sum() const
Definition: SparseRedux.h:30
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83

References Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::sum().