[−][src]Function arrayfire::sum
pub fn sum<T>(input: &Array<T>, dim: i32) -> Array<T::AggregateOutType> where
T: HasAfEnum,
T::AggregateOutType: HasAfEnum,
Sum elements along a given dimension
Parameters
input
- Input Arraydim
- Dimension along which the input Array will be reduced
Return Values
Result Array after summing all elements along given dimension
Examples
use arrayfire::{Dim4, print, randu, sum}; let dims = Dim4::new(&[5, 3, 1, 1]); let a = randu::<f32>(dims); print(&a); let b = sum(&a, 0); print(&b); let c = sum(&a, 1); print(&c);