Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.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 
7 int main()
8 {
9  Eigen::MatrixXf m(2,4);
10  Eigen::VectorXf v(2);
11 
12  m << 1, 23, 6, 9,
13  3, 11, 7, 2;
14 
15  v << 2,
16  3;
17 
18  MatrixXf::Index index;
19  // find nearest neighbour
20  (m.colwise() - v).colwise().squaredNorm().minCoeff(&index);
21 
22  cout << "Nearest neighbour is column " << index << ":" << endl;
23  cout << m.col(index) << endl;
24 }
Matrix3f m
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Definition: BFloat16.h:88
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Array< int, Dynamic, 1 > v


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:38