numas/mathematic/mod.rs
1use array::Array;
2
3
4/// Applies given function on given array elements and returns new array
5///
6/// # Arguments
7///
8/// * `array` - source array
9/// * `function` - function to apply
10fn apply<T, S, R>(array: &Array<T>, function: S ) -> Array<R>
11 where T: Copy, R: Copy, S: FnMut(&T) -> R,
12{
13 let old_data = array.data.borrow();
14 let data: Vec<R> = old_data[array.shape().get_bounds()].iter().map(function).collect();
15
16 return Array::new(data, array.get_shape().clone());
17}
18
19mod hyperbolic;
20mod trigonometric;
21mod reducer;
22mod miscellaneous;
23mod round;
24mod logarithm;
25mod exponential;