Skip to content

Commit f72d7a0

Browse files
committed
Clean up
1 parent fc54bbc commit f72d7a0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/inner.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
use crate::types::*;
22
use ndarray::*;
33

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>;
715
}
816

9-
impl<A, S1, S2> Inner<S1> for ArrayBase<S2, Ix1>
17+
impl<A, S> InnerProduct for ArrayBase<S, Ix1>
1018
where
1119
A: Scalar,
12-
S1: Data<Elem = A>,
13-
S2: Data<Elem = A>,
20+
S: Data<Elem = A>,
1421
{
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 {
1624
Zip::from(self)
1725
.and(rhs)
1826
.fold_while(A::zero(), |acc, s, r| FoldWhile::Continue(acc + s.conj() * *r))

0 commit comments

Comments
 (0)