This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Customize Eigen3

Tags: None
(comma "," separated)
ried_se
Registered Member
Posts
2
Karma
0

Customize Eigen3

Wed Jul 06, 2011 7:59 pm
Hello,

we need a P=UDU' decomposition for an algorithm (U = unit upper triangular, D = diagonal) and hence thought of customizing Eigen in way which would make the following statement possible:

Code: Select all
Eigen::Matrix<double, 10, 10> m;
...
//print factorized matrix
cout << m.factorizeUD() << endl;


We already tried to add a corresponding method to MatrixBase via the customizing tutorial, but had only partial success. The function looked something like:

Code: Select all
MatrixBaseAddons.h
...
Eigen::MatrixBase<Derived> factorizeUD()
{
...
Eigen::MatrixBase<Derived> result;
...
return result;
};


Whereas it seemed to work, when called from a ordinary Eigen::Matrix, calling above function from a Eigen::Map<Matrix<...>> we get segmentation faults. It probably has somehting to do with the Derived type.

Can somebody clearify how such a function would be added to Eigen in a way that works an Matrixes and Maps.

Best regards,
Sebastian
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Customize Eigen3

Wed Jul 06, 2011 8:56 pm
if you want to return a matrix, then use the PlainObject type which should be readily available at this stage:

PlainObject factorizeUD() {
PlainObject res;
return res
}
ried_se
Registered Member
Posts
2
Karma
0

Re: Customize Eigen3

Thu Jul 07, 2011 8:59 pm
Thank you, this works.

One additional question: What is the supposed data type to be used when a function should accept any kind of matrix as parameter (dynamic, fixed size matrices and Maps of matrices).

I tried with 'void function(MatrixXd &m){};' but this made problems. I don't remember exactly, but either fixed size matrixes or mapped fixed size matrixes gave compiler errors.

Should the PlainObject-type be used again?

Regards,
Sebastian
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Customize Eigen3

Thu Jul 07, 2011 9:57 pm
you need to define a template function taking a MatrixBase<Derived>. see this:

http://eigen.tuxfamily.org/dox/TopicFun ... Types.html


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]