![]() Registered Member ![]()
|
Given a vector v,
-- VectorXd v(100); -- v.setRandom(100, 1); I'd like to have another vector comprised of accumulated sum of the vector, that is -- VectorXd v_accum(100); -- v_accum << v(0), v(0) + v(1), v(0) + v(1) + v(2), ....., v(1) + v(2) + v(3) + ... + v(98) + v(99); Although there is a routine sum(), I can't find the efficient routine for doing accumulated sum. Is there any ? Or could you suggest sum efficient method to do it? Thanks in advance. |
![]() Moderator ![]()
|
This is also often called a "prefix sum", but there is no such function in Eigen yet.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]