Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp File Reference

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 4 of file Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp.

5 {
6  Eigen::MatrixXf m(2,4);
8 
9  m << 1, 23, 6, 9,
10  3, 11, 7, 2;
11 
12  v << 2,
13  3;
14 
15  Eigen::Index index;
16  // find nearest neighbour
17  (m.colwise() - v).colwise().squaredNorm().minCoeff(&index);
18 
19  std::cout << "Nearest neighbour is column " << index << ":" << std::endl;
20  std::cout << m.col(index) << std::endl;
21 }
Matrix3f m
Array< int, Dynamic, 1 > v
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82