Re: [eigen] Inverse of an array through .matrix() |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] Inverse of an array through .matrix()*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Sun, 27 Jun 2010 10:01:40 -0400*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ud+vu8hUB2Lkn4VevTIcKNYG8/lfvd/WWvF0xAciY4Q=; b=cW7QKfBEyUhPtk9z+WexL1rstqxA+ILR3uTjIE+/dqYG4C2BhZthn2aF9fX7IbKGtC lDe57z/c1HDNWg0ZUkKVRstMQypGvFucEU7GW45k8OwKjCZEjY94qAaiL7NWTcJB0tYa wM4IUPl1DFEKU49+qCdhVrIhsoclIQRP4QzVM=*Domainkey-signature*: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=PAgqX2HzihbZDTOvVjZKLMuHW4soyJMS0jDNbxBUSgrXsj1ENmS8z6bxujkDXK3YPT /1hh2iQbys/rpVESlB2d4oaE2OY18bUgXrZc6DOf8YdsHLvhdJnq/c4po69rA864CMj9 MkpW+s9hv+Z4JZ8nKK7qpywlMu97yL+7mdTRk=

2010/6/27 Carlos Becker <carlosbecker@xxxxxxxxx>: > Ok great, so I should point out that .matrix() and .array() can be lvalues > and rvalues, yes, > and also point out that conversion between matrix and array is > not always automatic Be more precise: mixing matrix and array in an expression is forbidden; while assigning a matrix to an array (or conversely) is allowed. Benoit (or at least remove it, since i was saying this was > true). > Any comments on this? > > On Sun, Jun 27, 2010 at 2:41 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> > wrote: >> >> 2010/6/27 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>: >> > On Sun, Jun 27, 2010 at 2:21 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> >> > wrote: >> >> 2010/6/27 Carlos Becker <carlosbecker@xxxxxxxxx>: >> >>> Hi everyone again. I am still writing some examples for the tutorials >> >>> and >> >>> came out with the following piece of code: >> >>> #include <Eigen/Dense> >> >>> #include <iostream> >> >>> using namespace Eigen; >> >>> using namespace std; >> >>> int main() >> >>> { >> >>> ArrayXXf m(2,2); >> >>> m << 1,2,3,4; >> >>> // this compiles OK >> >>> MatrixXf ww = m.matrix().inverse(); >> >>> // ERROR: no matching function for call to >> >>> ‘Eigen::TriangularView<Eigen::Matrix<float, 33331, 33331, 0, 33331, >> >>> 33331>, >> >>> 2u>::solveInPlace(.... >> >>> ArrayXXf xx = m.matrix().inverse(); >> >> >> >> That can't work: m.matrix().inverse() wants to return a matrix >> >> expression, so you can't assign that to an array expression. This >> >> works: >> >> >> >> ArrayXXf xx = m.matrix().inverse().array(); >> > >> > >> > on the other hand: >> > >> > MatrixXf m1, m2; >> > ArrayXXf a = m1 + m2; >> > >> > is legal and works fine. >> >> Thanks for the heads up, i had forgotten that this was legal. Makes sense! >> >> Benoit >> >> > What is not allowed is to mix matrix and >> > array in the right and side (e.g., array+matrix is forbidden). What >> > happens here is that .inverse() returns a proxy object which is >> > compiled as: >> > >> > m.matrix().lu().compute_the_inverse_into(xx); >> > >> > (the function compute_the_inverse_into does not exist, it is just to >> > get the idea) >> > >> > => we are mixing matrix and arrays. >> > >> > However, I think it is fine that this example does not compile, >> > because it does not make sense to do pure linear algebra on arrays. >> > >> > gael >> > >> > >> >> >> >> Notice that eigen3's .matrix() and .array() are very different from >> >> eigen2's .cwise(): while .cwise() was just a prefix for the next >> >> method call, .matrix() and .array() are permanently switching your >> >> expression between the Matrix and Array worlds. >> >> >> >> Please don't mention .inverse() in the Array page, as >> >> - it is nontrivial linear algebra so should not be mentioned before >> >> the linear algebra page >> >> - implementation-wise it is very nontrivial and special, whence the >> >> weird error messages that you got. >> >> >> >> Benoit >> >> >> >> >> >>> } >> >>> I just wanted to ask if this is the way it should work or not, since I >> >>> supposed that the last line should be fine. >> >>> Thanks. >> >> >> >> >> >> >> > >> > >> > >> >> > >

**References**:**[eigen] Inverse of an array through .matrix()***From:*Carlos Becker

**Re: [eigen] Inverse of an array through .matrix()***From:*Benoit Jacob

**Re: [eigen] Inverse of an array through .matrix()***From:*Gael Guennebaud

**Re: [eigen] Inverse of an array through .matrix()***From:*Benoit Jacob

**Re: [eigen] Inverse of an array through .matrix()***From:*Carlos Becker

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Inverse of an array through .matrix()** - Next by Date:
**[eigen] block of dense-block should again be block** - Previous by thread:
**Re: [eigen] Inverse of an array through .matrix()** - Next by thread:
**[eigen] block of dense-block should again be block**

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