AtheMathmo / rulinalg

A linear algebra library written in Rust
https://crates.io/crates/rulinalg
MIT License
288 stars 58 forks source link

Cannot compute induced metric of two `MatrixSlice`s #154

Closed AtheMathmo closed 7 years ago

AtheMathmo commented 7 years ago

The current trait bounds restrict us taking the metric of two slices. It looks like this:

impl<'a, 'b, U, T, M1, M2> MatrixMetric<'a, 'b, T, M1, M2> for U
    where U: MatrixNorm<T, M1>,
    M1: 'a + BaseMatrix<T>,
    M2: 'b + BaseMatrix<T>,
    &'a M1: Sub<&'b M2, Output=M1> {

    fn metric(&self, m1: &'a M1, m2: &'b M2) -> T {
        self.norm(&(m1 - m2))
    }
}

The issue is the last line of the where clause. We require that the output be of type M1 but this is not the case for slices. I think we can remedy this by requiring that the Output is a Matrix<T>.