source: pacpussensors/trunk/Vislab/lib3dv/eigen/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 440 bytes
Line 
1#include <iostream>
2#include <Eigen/Dense>
3
4using namespace std;
5using namespace Eigen;
6
7int 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}
Note: See TracBrowser for help on using the repository browser.