Boost logo

Ublas :

Subject: Re: [ublas] Conflicting operator == in ublas
From: K.M.A.Chai_at_[hidden]
Date: 2008-12-10 20:05:00


Thank you for the clarification. I'm still slightly confused here, though.

I (mis?)understand that "pointing to the same location" is provided for the the
same_closure member function, that the same_closure of matrix_row (for
example) does not check for the equality in row index, i.e.

matrix_row:
         BOOST_UBLAS_INLINE
         bool same_closure (const matrix_row &mr) const {
             return (*this).data_.same_closure (mr.data_);
         }

         // Comparison
         BOOST_UBLAS_INLINE
         bool operator == (const matrix_row &mr) const {
             return (*this).data_ == mr.data_ && index () == mr.index ();
         }

Would it not be better to remove operator== to prevent confusion and to
enforce consistency, even though it is not part of th vector_expression
concept proper?

Kian Ming (Adam)

On Wed, 10 Dec 2008, Gunter Winkler wrote:

> Am Mittwoch, 10. Dezember 2008 14:42 schrieb K.M.A.Chai_at_[hidden]:
>> Hi,
>>
>> The following
>>
>> grep -R "operator ==" ublas/* | grep -v "iterator"
>>
>> produces, for example:
>>
>> ublas/detail/concepts.hpp:718:
>> operator == (const vector_expression<E1> &e1, const
>> vector_expression<E2> &e2) {
>>
>> and
>>
>> ublas/matrix_proxy.hpp:180:
>> bool operator == (const matrix_row &mr) const {
>>
>> It seems that the definition of operator== in the proxies does not
>> agree with the concept.
>>
>> For example, in matrix_row, which is derived from a
>> vector_expression, two rows are equal iff they are the same indexes
>> into the same matrices. This conflicts the definition in
>> ublas/detail/concept, where it is stated that two vectors are equal
>> if their norm_inf are zero.
>
> The operator== () is not part of the vector expression concept. Thus
> vector expressions do not need to provide it. The operator==() of some
> proxies is only provided for convenience and means "points to the same
> location". It does not mean "has the same entries".
>
> The operator==() in concepts.hpp is only provided to simplify the syntax
> of the rules to be checked. It is not provided for general use.
>
> mfg
> Gunter
>
>
>
>

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.