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 }
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
std
Definition: BFloat16.h:88
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
main
int main()
Definition: Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp:7
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 Sun Dec 22 2024 04:18:19