Registered Member
|
Hi all,
First of all, I would like to extend my congratulations for what appears to be a fine library with a bright future. I've been looking for something like this for about four years. Let's hope I must look no further Secondly, since this is my first post in the list, I apologize if these subjects have been previously posted. I looked around in the archives and did not find anything similar. I have a question that is very specific to our use case, and wanted to have some feedback on what the best practice should be: We deal with a real-time robotics application that must perform heavy matrix operations (products, SVDs, etc.). The usual matrix sizes we're talking about have about 30 columns (a fixed value), and up to 30 rows (a value that may change at runtime). As a requirement, we are to avoid dynamic allocations during the real-time parts of our code, so the question would be: a) Is there any way of preallocating memory for a matrix (something like std::vector's reserve method)?. This would guarantee no extra allocations as long as the matrix does not exceed its preallocated size, and preserve notational convenience when calling matrix operations (see point c) for more details) b) If the answer is negative, is there any interest/previsions in supporting such a feature? c) If the answer is still negative, what would be the recommended way of handling this scenario?. The straightforward solution that comes to my mind would be to create a matrix with the maximum expected size, keep a count of the used rows, and extract the used submatrix before every operation, but ease of use and notational convenience take a big hit. Any ideas are welcome. Thanks in advance! -- Adolfo Rodríguez Tsouroukdissian Robotics engineer PAL ROBOTICS S.L http://www.pal-robotics.com Tel. +34.93.414.53.47 Fax.+34.93.209.11.09
Last edited by ggael on Mon Mar 09, 2009 11:16 am, edited 1 time in total.
|
Registered Member
|
Re-reading the recent post titled How to resize properly big matrices I'm thinking that using EIGEN_MATRIX_PLUGIN might be the way to do it. Do you agree?
Thanks once again, Adolfo
|
Registered Member
|
I think that the easiest way is to use a Map object.
Notice that when the Map object is a temporary and you don't need to name it, it can be more convenient to use the MatrixXf::Map() static methods. If you really know at compile-time that the number of columns is 30, you can let Eigen know about that:
Also notice that it can greatly help performance (vectorization) to use an aligned array and let Eigen know about that. Like this:
Gael: is this ForceAligned safe here? What I really want is to set the AlignedAccessBit on this xpr. The convenience methods MapAligned used to do just that, but now they're wrapping around ForceAligned. Is this really intended or a mistake?
Last edited by bjacob on Fri Mar 06, 2009 7:01 pm, edited 1 time in total.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Gael: when writing this answer, playing with RowMajor and ColMajor storage, I realized that 0 is DontAlign, so we have to specify AutoAlign explicitly when we specify storage order. My fault. That's stupid isn't it? 99% of people want AutoAlign.
Is it worth (or even possible) changing? This would break the ABI. KDE would be unaffected as no stable library exposes Eigen. But for example, for Avogadro, we would have to do such a change very quickly as they'll soon release their 1.0 library.
Last edited by bjacob on Fri Mar 06, 2009 7:02 pm, edited 1 time in total.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Moderator
|
hm, if the max sizes are known at compile time, then the easiest way is to declare your matrix like this:
this will allocate on the stack 30x30 floats and let you dynamically change the number of rows without any reallocation. |
Moderator
|
damn it! actually I thought we already did that change, but it seems we noticed that issue without fixing it. So yes I think that would nice to do that change if possible. |
Registered Member
|
You're perfectly right! Goes to show i haven't been coding for a too long time....
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell