Registered Member
|
Hi there,
I just start to use Eigen in C++. I am trying to do an element-wise product of two arrays, as followings ArrayXd p(M), p1(N), p2(N); for (int i=0; i < N_tau; i++) { p.segment(0, M-1) = p1.segment(0, M-1)*p2.segment(i, M-1+i); } Provided all p, p1 and p2 are well initialized with nonzero values. Also N is much greater than M+N_tau... It returns me the error: Assertion failed: (aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()), function CwiseBinaryOp, file /usr/local/include/Eigen/src/Core/CwiseBinaryOp.h, line 132. What is the best way to do the product? In Matlab it would be just like for i = 1: N_tau p = p1(1:M).*p2(i:M-1+i) end Thanks in advance! Best regards |
Moderator
|
The arguments of segment are 1) starting position, and 2) the length of the segment, and not the index of the last element.
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]