I'm trying to find the min element as follows:
#include <algorithm>
#include <iostream>
#include <vector>
#include <Eigen/Dense>
using namespace std;
template<typename T>
bool isLeftOf(const Eigen::Vector2<T>& a,
const Eigen::Vector2<T>& b) {
return (a.x() < b.x() || (a.x() == b.x() && a.y() < b.y()));
}
int main(int argc, char *argv[])
{
std::vector<Eigen::Vector2<float> > points;
points.push_back(Eigen::Vector2<float>(-1, -1));
points.push_back(Eigen::Vector2<float>(1, -1));
points.push_back(Eigen::Vector2<float>(0.5, 0));
points.push_back(Eigen::Vector2<float>(1, 1));
points.push_back(Eigen::Vector2<float>(0, 1.5));
points.push_back(Eigen::Vector2<float>(-1, 1));
points.push_back(Eigen::Vector2<float>(-0.7, 0));
Eigen::Vector2<float> outpointa = min_element(*points.begin(),
*points.end(), isLeftOf<float>);
return 0;
}
But I get compiler error:
...\algorithm(9199): error C2675: unary '++': '_FwdIt' does not define this operator or a conversion to a type acceptable to the predefined operator with [ _FwdIt=Eigen::Matrix<float,2,1,0,2,1> ]
How to overcome this?
you need to provide iterators to min_element
this will do , no need to dereference the iterators.
Eigen::Vector2<float> outpointa = min_element(points.begin(),
points.end(), isLeftOf<float>);