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

opertor+ between vectors and matrices

Tags: None
(comma "," separated)
rtrepos
Registered Member
Posts
11
Karma
0
Hello,
Is there a way to add vectors to matrices ?
for example :

Code: Select all
MatrixXd m1(2, 2);
m1 << 3,1,
      2,5 ;
VectorXd v(2);
v << 5,
     8 ;



and v + m1 could give

8,6,
10,13


I did not find,
Thank you in advance.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
We don't allow that by default as it does not make sense. However you can still achieve this using this explicit expression:

m1.colwise() + v
rtrepos
Registered Member
Posts
11
Karma
0
Thank you for your response
but it does not compile,
the error is

/home/rtrepos/usr/src/vle_dev/eigen_utils/src/test_eigen_utils.cpp: In function ‘int main(int, const char**)’:
/home/rtrepos/usr/src/vle_dev/eigen_utils/src/test_eigen_utils.cpp:159: error: no match for ‘operator+’ in ‘((Eigen::MatrixBase<Eigen::Matrix<double, 10000, 10000, 2, 10000, 10000> >*)(& m1))->Eigen::MatrixBase<Derived>::colwise [with Derived = Eigen::Matrix<double, 10000, 10000, 2, 10000, 10000>]() + v’
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
ah sorry, this is only in the devel branch. so you can either switch to it (basic features are very stable) or wait until the 3.0 version is out (in a couple of months).
rtrepos
Registered Member
Posts
11
Karma
0
Ok thank you,
I will wait for the next version.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]