What are practical uses for STL's 'partial_sum'?

前端 未结 11 1703
耶瑟儿~
耶瑟儿~ 2021-02-04 03:47

What/where are the practical uses of the partial_sum algorithm in STL?

What are some other interesting/non-trivial examples or use-cases?

11条回答
  •  醉梦人生
    2021-02-04 04:41

    I often use partial sum not to sum but to calculate the current value in the sequence depending on the previous.

    For example, if you integrate a function. Each new step is a previous step, vt += dvdt or vt = integrate_step(dvdt, t_prev, t_prev+dt);.

提交回复
热议问题