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

[ Thread Index | Date Index | More Archives ]

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

 ArrayXXf xx = m.matrix().inverse().array();

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.


> }
> 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.

Mail converted by MHonArc 2.6.19+