Registered Member
|
Hi,
I'm working on porting a library of mine from LAPACK++ to Eigen. In the past, I've relied heavily on LAPACK++'s submatrix views (via the LaIndex class), which are represented by blocks in Eigen. I also created sub-blocks of blocks, which was trivial in LAPACK++ because all submatrix views also are objects of type LaGenMatDouble, the default matrix type. As VectorXd and Block<VectorXd> seem to be not interoperable (as stated in http://eigen.tuxfamily.org/dox/TopicFun ... Types.html), I figured I could just use Block<VectorXd> as arguments for some of my subroutines. However, there's still a problem with recursion: It seems like creating a block from a block generates an object of type Block< Block<VectorXd> > rather than a new Block<VectorXd>. Is there any way to avoid this in order to e.g. restrict blocks to an even smaller sub-range of the underlying vector? In this case, using argument templates wouldn't help because it would lead to an "infinite recursion" of templates, i.e. Block<VectorXd>, Block< Block<VectorXd> >, Block< Block<Block<VectorXd> > > etc. A similar question: Some of my functions take a vector (or a Block<VectorXd>, for that matter) as argument, but I'd like to use them on single columns of matrices, too. So is there a straightforward way to convert a single column (or row) of a matrix to a Block<VectorXd>? Best, Daniel |
Moderator
|
Currently the only general way to accept any kind of expression is to 'templatize' your functions, but there is a plane to address your use case which appears to be quite common:
http://listengine.tuxfamily.org/lists.t ... 00062.html |
Registered Member
|
Thank you for the tip. It appears to me that the following code
There still remains the problem of using such a map as an lvalue: Some of my subroutines need to write to their arguments, so I pass those as a reference to MapXd (e.g. "void writeData(MapXd & output)" rather than "void writeData(const MapXd & output)"). Then, however, calling "writeData(toMap(myMatrix))" fails because "toMap(myMatrix)" can't be used as an lvalue (error code "Non-const lvalue reference to type 'MapXd'..." in Clang). So I have to write
Another question: In some of my modules, the code
|
Moderator
|
For your first question: that's a general C++ issue, and there is no ideal solution. With C++11 new features you can probably use rvalue references and/or move semantic for that purpose.
A simple solution is to pass the Map<> object by value rather than by reference. Map objects are very lightweight. Another solution is to use a 'const Map<Type>&' and const cast the map object. Note that in Eigen a Map<Type> is different to a Map<const Type>. So if you update your toMap wrapper to properly take care of constness you should be fine. Your const arguments should then be declared using 'const Map<const Type>&'. |
Registered Member
|
I encountered exactly the same abiguous operator= with Clang 3.1 and col instead of row like MrMage did (see below). Is there any workaround to fix this?
|
Registered Member
|
My solution was to comment out in MatrixBase.h:
For completeness, here's the final code arrived at in order to obtain maps from any kind of Eigen objects:
|
Moderator
|
sbirk: I cannot reproduce. Here is my test program:
|
Registered Member
|
I could only reproduce the issue within templated classes with Clang. Here's a test case that doesn't compile for me:
|
Registered Member
|
Sorry, I should have supplied you with an example in the first place. The code below is a stripped down example of the code causing the ambiguity. Compiling with
works well, but
fails. Here is the code:
|
Registered Member
|
Thanks. This seems to be working well. I just used
|
Moderator
|
ok, now I can reproduce. However the workaround will be more complicated.
We should also report to clang because this is clearly a compiler bug. Any volunteer? |
Registered Member
|
Maybe we could narrow down the test case so that it doesn't have to include the whole Eigen library in order to fail? I would then file a bug with Apple (in fact, the more people file the bug, the quicker it gets fixed).
|
Registered Member
|
I agree, that for this bug report the Eigen library should be condensed to only the necessary parts to illustrate the bug. But I'm afraid that I don't know the internals well enough to do this.
|
Registered Member
|
Any update on a proper workaround? My workaround leads to an error "/Users/daniel/Documents/Xcode/Uni/eigen/Eigen/src/Core/DenseBase.h:508:65: No member named 'THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS' in 'Eigen::internal::static_assertion<false>'" with the following code:
|
Registered Member
|
I would just like to add that I am also experiencing this problem. Was it reported to Apple/Clang? I don't understand Eigen's internals well enough to file a meaningful bug report myself.
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]