forked from M-Labs/nalgebra
19 lines
361 B
Rust
19 lines
361 B
Rust
|
use allocator::Allocator;
|
||
|
use {DefaultAllocator, Dim, VectorN};
|
||
|
|
||
|
pub fn cumsum<D: Dim>(a: &mut VectorN<usize, D>, b: &mut VectorN<usize, D>) -> usize
|
||
|
where
|
||
|
DefaultAllocator: Allocator<usize, D>,
|
||
|
{
|
||
|
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
|
||
|
}
|