Re: [eigen] Commenting issue #110, disabling operator[] for matrices |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Commenting issue #110, disabling operator[] for matrices
- From: Márton Danóczy <marton78@xxxxxxxxx>
- Date: Thu, 22 Apr 2010 14:39:25 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:content-type :content-transfer-encoding; bh=S2nJMlZlnpKrG+6u1d1fo8toQNyJXKEOrLIW7LNRHtg=; b=DqzlWt6No3AjlRqlrHSnytaz8Q9coIN1VvxSLpZXz2i3sQV54jWnvfkda/KxaFYFfJ XJI+BWKcFRPIPEHOn2cDdRYrn1H547FhWZgL44BC/Q1qXIuD6w+cQfO84igFfZ/jejz+ qz29e+LO1ET83lXOhDTpY58x9WeI2p6sfS2lM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=YQXGqJbCsUrfL+hSHA7UD0v4oasnSSBLHISJsHTRBrkbWkB7YcHavekMgI8NV3Hx1R /PonWgymiZYm15S4sxvVtffmbN31TwD8BArmbgCY7gm03HBXBevCOG0yyva6K9j0Y2nI hJz/M9KyWx9MPVFJiva0nHk90s95I2qeTo6to=
In my opinion matrix(i) should be disallowed as well, I'd guess in
most of the cases matrix(i) means that the user mistakenly believes
the matrix to be a vector. I'd go for the more verbose but
self-documenting .asVector(i).
Just my two cents.
Marton
On 22 April 2010 14:34, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> Hi,
>
> https://bitbucket.org/eigen/eigen/issue/110/disabling-operator-for-a-matrix
>
> here we are discussing disabling operator[] on matrices.
>
> We can perfectly disable it on matrices while keeping it on vectors
> (e.g. with a static assertion).
>
> The motivation for disabling it on matrices is to guard against this
> dreadful c++ code:
>
> matrix[i,j]
>
> which in c++ compiles as
>
> matrix[i]
>
> which addresses the i-th entry in the storage order of the matrix.
>
> If you want that functionality, there still is the synonym
>
> matrix(i)
>
> And the method coeff(int) if you want to avoid the assertion.
>
> People have already proposed adding an expression to view a matrix as
> a vector, following its storage order. But you can already do that
> with Map. If you really want, we can add a conveniene method
> asVector() to return such a Map object. But given the possibility of
> doing matrix(index), i don't see too much motivation for that...
>
> Benoit
>
>
>