I have a vector of doubles and I need to create another array which is the cumulative sum of the first elements. for example;
vector & lt; Double & gt; Array (10,1); Of vector & lt; Double & gt; Sum Insured (10); Sum [0] = array [0]; For (unsigned int i = 1; i & lt; Array.size (); i ++) Yoga [i] = Yoga [i-1] + array [i]; Is there a built-in function that will fulfill the above cumulative amount?
Without testing,
std :: partial_sum (Array. Start, Array.end (), Sum.begin (), plus < Double & gt; ());
should do the trick, if it is C ++ (in fact, plus can be defaults. )
Comments
Post a Comment