Skip to main content

cumsum

Function cumsum 

Source
pub fn cumsum<B: Backend, T: Numeric>(
    x: impl ArrayLike<B, T>,
    axis: Option<i64>,
) -> Array<B, T>
Expand description

The cumulative sum along axis (of the flattened array for None), in the input type.

ยงExamples

use ruxla_core::{Array, Native, jnp};

let x = Array::<Native, f32>::from_vec(vec![1.0, 2.0, 3.0, 4.0], [2, 2]);
assert_eq!(jnp::cumsum(&x, Some(1)).to_vec(), [1.0, 3.0, 3.0, 7.0]);
assert_eq!(jnp::cumsum(&x, None).to_vec(), [1.0, 3.0, 6.0, 10.0]);