File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: types:: * ;
2
2
use ndarray:: * ;
3
3
4
- pub trait Inner < S : Data > {
5
- /// Inner product `(self.conjugate, rhs)`
6
- fn inner ( & self , rhs : & ArrayBase < S , Ix1 > ) -> S :: Elem ;
4
+ /// Inner Product
5
+ ///
6
+ /// Differenct from `Dot` trait, this take complex conjugate of `self` elements
7
+ ///
8
+ pub trait InnerProduct {
9
+ type Elem : Scalar ;
10
+
11
+ /// Inner product `(self.conjugate, rhs)
12
+ fn inner < S > ( & self , rhs : & ArrayBase < S , Ix1 > ) -> Self :: Elem
13
+ where
14
+ S : Data < Elem = Self :: Elem > ;
7
15
}
8
16
9
- impl < A , S1 , S2 > Inner < S1 > for ArrayBase < S2 , Ix1 >
17
+ impl < A , S > InnerProduct for ArrayBase < S , Ix1 >
10
18
where
11
19
A : Scalar ,
12
- S1 : Data < Elem = A > ,
13
- S2 : Data < Elem = A > ,
20
+ S : Data < Elem = A > ,
14
21
{
15
- fn inner ( & self , rhs : & ArrayBase < S1 , Ix1 > ) -> A {
22
+ type Elem = A ;
23
+ fn inner < St : Data < Elem = A > > ( & self , rhs : & ArrayBase < St , Ix1 > ) -> A {
16
24
Zip :: from ( self )
17
25
. and ( rhs)
18
26
. fold_while ( A :: zero ( ) , |acc, s, r| FoldWhile :: Continue ( acc + s. conj ( ) * * r) )
You can’t perform that action at this time.
0 commit comments