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
ArrayXcf v
Definition: Cwise_arg.cpp:1
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Definition: Half.h:150
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:51:19