Re: [eigen] operator== (and probably others) for 0-sized Eigen-types |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] operator== (and probably others) for 0-sized Eigen-types*From*: Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>*Date*: Tue, 12 Nov 2013 00:44:26 +0100

On 11.11.2013 23:59, Gael Guennebaud wrote:

Hi, I cannot reproduce the compilation issue with both gcc and clang. Here is what I tested: #include <Eigen/Core> #include <iostream> int main() { Eigen::Matrix<double, 1, 0> A, B; std::cout << (A == B) << "\n"; }; However, it currently returns false, while returning true seems to be more appropriate. Actually the problem might be more general because it raises the question of what should be the result of .all() and .any() on an empty matrix of bool? Currently both returns false, that is why operator== returns false too since A==B on Matrices is implemented as: (A.array()==B.array()).all() One option could be to make .all() and .any() returns the identity element of the operators && and || respectively, i.e., true and false. This choice would even be compatible with the following identities:

Yes, that is also exactly what a mathematician would expect for empty sets.

(A.array()==B.array()).all() <=> (A==B) (A.array()!=B.array()).any() <=> (A!=B)

Yes, again that is basic quantification logic: ( \neg(\forall x: P(x)) ) = (\exist x: \neg P(x)), or in Eigen syntax: (!(A.all())) == ((!A).any()); assuming A is a boolean array.

However it would break a more fundamental identity that is: expression.all() => expression.any()

Moreover, it seems to me that an 'ideal' result of all() and any() on zero-sized objects depend on the context, e.g: (A.array()==B.array()).all() == (A.array()==B.array()).any() == true (A.array()!=B.array()).all() == (A.array()!=B.array()).any() == false

Christoph -- ---------------------------------------------- Dipl.-Inf., Dipl.-Math. Christoph Hertzberg Cartesium 0.049 Universität Bremen Enrique-Schmidt-Straße 5 28359 Bremen Tel: +49 (421) 218-64252 ----------------------------------------------

**References**:**[eigen] operator== (and probably others) for 0-sized Eigen-types***From:*Daniel.Vollmer

**Re: [eigen] operator== (and probably others) for 0-sized Eigen-types***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] operator== (and probably others) for 0-sized Eigen-types** - Next by Date:
**Re: [eigen] operator== (and probably others) for 0-sized Eigen-types** - Previous by thread:
**Re: [eigen] operator== (and probably others) for 0-sized Eigen-types** - Next by thread:
**Re: [eigen] operator== (and probably others) for 0-sized Eigen-types**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |