[eigen] Commenting issue #110, disabling operator[] for matrices |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: [eigen] Commenting issue #110, disabling operator[] for matrices
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 22 Apr 2010 08:34:05 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=O+IGIDdotEMaAq6pLu3rhH9rjMfyyjsDik1qINwmH4c=; b=Zyx/wtXveG7fwaPabz2Bn7BxKEyDAW+0d3oE7bUuK6mXEf/2ekHG+pVDAmQEwxSPpy 9uCh8Hej0yjVwf3CPGyOO0ZqegHIbKt3BbAYsZDaNJMRMe59hCFZkem8uAIXmhrQ1Fir UZ3LvJkXdUWOUZMhp9kDe6NAIlozoMcYn48+k=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=sZwPB3tFEd/ZOqwA52YSw36uI29wZ+7sHunGi1NLppV/WhrG/XREBvun98+vAShGP5 RgXhG6Ur9q4xlBxo3F1MSzo7kqWqEwVUPNWUCVZFk0C3QpmfvJPyjfgsC3V6hOmdtBw/ Z9HV2iaOoMPUX7BmhkLukYqRk7nMMh414TYMw=
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