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: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Sun, 27 Jun 2010 15:13:23 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=KfbDwVlD287Dt/SevbvmzvYf5C5aPee4+rTgOzVbSSA=; b=TP5zd/Ewhaq2GVABbI9hy40jHXAWKWjALHlEUY8u5lFE6KR7GeYtqEc++gQabK304t bgjUX7eQ8yug0hqId6Wpt2zpDzwUIJugQkMPlcnL26OC1fl0Ah/HAkmdD2TCzSa6Tbmv 8p85NzscMdPdEflGmhCkzMfUPPKfjwa5YpIFw=
- 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=bRam9E+H1ZSfbh16OHOZvFaRFPEuF1NlKQFsQjL2e9HeDsYM+DtzSqChMOFXt5hoX8 +4lPNjD14GLPcV8MwlTZDqqlYcZw7xfYfZFNHsQx/TgsvKZx1jOqPV2QMZkINHy7Kpe9 SamXNTDk1IIkcqxQzRQ4BHeppsFfmb24jBBNg=
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. 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.
>
>
>