2019-03-23 21:29:07 +08:00
|
|
|
use crate::allocator::Allocator;
|
2021-04-11 17:00:38 +08:00
|
|
|
use crate::{DefaultAllocator, Dim, OVector};
|
2018-11-07 01:31:04 +08:00
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn cumsum<D: Dim>(a: &mut OVector<usize, D>, b: &mut OVector<usize, D>) -> usize
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
|
|
|
DefaultAllocator: Allocator<usize, D>,
|
|
|
|
{
|
2018-11-07 01:31:04 +08:00
|
|
|
assert!(a.len() == b.len());
|
|
|
|
let mut sum = 0;
|
|
|
|
|
|
|
|
for i in 0..a.len() {
|
|
|
|
b[i] = sum;
|
|
|
|
sum += a[i];
|
|
|
|
a[i] = b[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
sum
|
|
|
|
}
|