mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-24 02:29:33 +08:00
24 lines
501 B
C++
24 lines
501 B
C++
#include <iostream>
|
|
#include <Eigen/Dense>
|
|
|
|
int main()
|
|
{
|
|
Eigen::MatrixXf m(2,2);
|
|
|
|
m << 1, 2,
|
|
3, 4;
|
|
|
|
//get location of maximum
|
|
Eigen::Index maxRow, maxCol;
|
|
float max = m.maxCoeff(&maxRow, &maxCol);
|
|
|
|
//get location of minimum
|
|
Eigen::Index minRow, minCol;
|
|
float min = m.minCoeff(&minRow, &minCol);
|
|
|
|
std::cout << "Max: " << max << ", at: " <<
|
|
maxRow << "," << maxCol << std::endl;
|
|
std:: cout << "Min: " << min << ", at: " <<
|
|
minRow << "," << minCol << std::endl;
|
|
}
|