Registered Member
|
Hello,
I want to know if at least one component of a VectorXd is greater than 1:
offset is a const Eigen::VectorXd&. but this gives the compiler error:
It's probably that Constant returns an expression. But what is way for doing comparisions like that one? I also tried (offset > 1) but there is no operator> for int. Thanks! Florian |
Moderator
|
It's easier to go to the "array" world:
(offset.array() > 1).any() |
Registered Member
|
Thanks, that works fine:
We used to have a function oneGreater, that I'm substituting with the code above. This function, however actually compared A-B > e, with a floating point precision e. Is there a way to set a floating point precision for comparision in Eigen? Thanks! |
Registered Member
|
Ok, I started to reimplement the oneGreater function
but where is Eigen::Index defined. The documentation says, one should use it for indexing, and it is the return type of size(). However, even grepping through the Eigen code case was not enlighting. |
Moderator
|
You can replace your loop by:
return ((A-B).array()>tolerance).all(); Eigen::Index is in 3.3 only. (file src/Core/util/Meta.h line 33) |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]