argmin_math/ndarray_m/
sub.rs1use crate::ArgminSub;
9use ndarray::{Array1, Array2};
10use num_complex::Complex;
11
12macro_rules! make_sub {
13 ($t:ty) => {
14 impl ArgminSub<$t, Array1<$t>> for Array1<$t> {
15 #[inline]
16 fn sub(&self, other: &$t) -> Array1<$t> {
17 self - *other
18 }
19 }
20
21 impl ArgminSub<Array1<$t>, Array1<$t>> for $t {
22 #[inline]
23 fn sub(&self, other: &Array1<$t>) -> Array1<$t> {
24 *self - other
25 }
26 }
27
28 impl ArgminSub<Array1<$t>, Array1<$t>> for Array1<$t> {
29 #[inline]
30 fn sub(&self, other: &Array1<$t>) -> Array1<$t> {
31 self - other
32 }
33 }
34
35 impl ArgminSub<Array2<$t>, Array2<$t>> for Array2<$t> {
36 #[inline]
37 fn sub(&self, other: &Array2<$t>) -> Array2<$t> {
38 self - other
39 }
40 }
41
42 impl ArgminSub<$t, Array2<$t>> for Array2<$t> {
43 #[inline]
44 fn sub(&self, other: &$t) -> Array2<$t> {
45 self - *other
46 }
47 }
48 };
49}
50
51make_sub!(i8);
52make_sub!(i16);
53make_sub!(i32);
54make_sub!(i64);
55make_sub!(u8);
56make_sub!(u16);
57make_sub!(u32);
58make_sub!(u64);
59make_sub!(f32);
60make_sub!(f64);
61make_sub!(Complex<f32>);
62make_sub!(Complex<f64>);
63
64#[cfg(test)]
68use crate as argmin_math;
69include!(concat!(
70 env!("CARGO_MANIFEST_DIR"),
71 "/ndarray-tests-src/sub.rs"
72));