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

[SOLVED] Summing a .asDiagonal() matrix

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

Trying to sum a matrix and a vector.asDiagonal() does not compile, e.g.:

Code: Select all
Eigen::Vector3f x;
Eigen::Matrix3f A,B;

B = A + x.asDiagonal();

gives the following error:
Code: Select all
error: no match for ‘operator+’ in ‘A + x.Eigen::Matrix<float, 3, 1, 0, 3, 1>::<anonymous>.Eigen::PlainObjectBase<Eigen::Matrix<float, 3, 1, 0, 3, 1> >::<anonymous>.Eigen::MatrixBase<Derived>::asDiagonal [with Derived = Eigen::Matrix<float, 3, 1, 0, 3, 1>]()’
/usr/include/c++/4.4/bits/stl_bvector.h:264: note: candidates are: std::_Bit_iterator std::operator+(ptrdiff_t, const std::_Bit_iterator&)
/usr/include/c++/4.4/bits/stl_bvector.h:350: note:                 std::_Bit_const_iterator std::operator+(ptrdiff_t, const std::_Bit_const_iterator&)


However, the following will compile:

Code: Select all
Eigen::Vector3f x;
Eigen::Matrix3f A,B;

B = A;
B += x.asDiagonal();


Am I doing something wrong here?

Thanks,
Bruno

Last edited by bdamas on Tue Jul 05, 2011 11:54 am, edited 1 time in total.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Summing a .asDiagonal() matrix

Mon Jul 04, 2011 4:45 pm
that's the intended behavior. the reason is that the expression "B = A + x.asDiagonal();" should be optimally evaluated as you did, i.e., in two steps. In Eigen 3.1 we'll be able to do so automatically in a general fashion, but currently you have to do this yourself.
bdamas
Registered Member
Posts
2
Karma
0

Re: Summing a .asDiagonal() matrix

Tue Jul 05, 2011 11:53 am
Thank you, Gaël!


Bookmarks



Who is online

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