concision_data/traits/ext/
ndtensor.rs1use nd::{ArrayBase, Data, Dimension, RawData};
6use num::complex::ComplexFloat;
7use num::traits::Float;
8
9pub trait Scalar {
10    type R: Float;
11}
12
13pub trait NdTensor<A, D>
14where
15    A: ComplexFloat,
16    D: Dimension,
17{
18    type Data: RawData<Elem = A>;
19    type Output;
20
21    fn conj(&self) -> Self::Output;
22
23    fn cos(&self) -> Self::Output;
24
25    fn cosh(&self) -> Self::Output;
26}
27
28impl<A, S, D> NdTensor<A, D> for ArrayBase<S, D>
32where
33    A: ComplexFloat,
34    D: Dimension,
35    S: Data<Elem = A>,
36    Self: Clone,
37{
38    type Data = S;
39    type Output = nd::Array<A, D>;
40
41    fn conj(&self) -> Self::Output {
42        self.mapv(|x| x.conj())
43    }
44
45    fn cos(&self) -> Self::Output {
46        self.mapv(|x| x.cos())
47    }
48
49    fn cosh(&self) -> Self::Output {
50        self.mapv(|x| x.cosh())
51    }
52}