Registered Member
|
Hi Friends,
I am dealing with <Eigen> library. I can cout<<(PointsSorted.col(0).array()<0)<<endl; The output is: 1 1 1 1 1 0 0 0 0 0 But how can I assign this output to a std::vector. I have a slow solution to do this by a pointer.I am wondering if there is a faster way like: vector<int> v; v.push_back((PointsSorted.col(0).array()<0)); But it does not work by this way. What's the problem? Does anyone know the type of (PointsSorted.col(0).array()<0)? L |
Moderator
|
For instance:
|
Registered Member
|
I tried this codes:
vector <int> v; int n = PointsSorted.rows(); v.resize(n); VectorXi::Map(v.data(), n) = (PointsSorted.col(0).array()<0).cast<int>(); and error message as: "error: no matching function for call to 'Map' VectorXi::Map(v.data(), n) = (PointsSorted.col(0).array()<0).cast<int>();" It seems that Map is to store std:: array into Eigen:: object. I need the opposite way. Thanks, L |
Moderator
|
This must work. Here is a self-contained working example:
|
Registered Member
|
No, same error:" no matching function for call to 'Map'
The documentation shows Map is under the class "Eigen::", not "VectorXi::", and the format is : class Eigen::Map< PlainObjectType, MapOptions, StrideType > I am confused.... L |
Registered Member
|
It works now. My bad.
Thanks for the help, L |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft