Tutorial_ReductionsVisitorsBroadcasting_broadcast_1nn.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <Eigen/Dense>
00003 
00004 using namespace std;
00005 using namespace Eigen;
00006 
00007 int main()
00008 {
00009   Eigen::MatrixXf m(2,4);
00010   Eigen::VectorXf v(2);
00011   
00012   m << 1, 23, 6, 9,
00013        3, 11, 7, 2;
00014        
00015   v << 2,
00016        3;
00017 
00018   MatrixXf::Index index;
00019   // find nearest neighbour
00020   (m.colwise() - v).colwise().squaredNorm().minCoeff(&index);
00021 
00022   cout << "Nearest neighbour is column " << index << ":" << endl;
00023   cout << m.col(index) << endl;
00024 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:33:27