More elegant initial value for xcmp

This commit is contained in:
Fabian Löschner 2019-08-13 09:04:41 +02:00 committed by Sébastien Crozet
parent 8916e907f2
commit 3ef76ab9e4
1 changed files with 1 additions and 4 deletions

View File

@ -871,10 +871,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
fn xcmp<N2>(&self, abs: impl Fn(N) -> N2, ordering: Ordering) -> N2 fn xcmp<N2>(&self, abs: impl Fn(N) -> N2, ordering: Ordering) -> N2
where N2: Scalar + PartialOrd + Zero { where N2: Scalar + PartialOrd + Zero {
let mut iter = self.iter(); let mut iter = self.iter();
let mut max = match iter.next() { let mut max = iter.next().cloned().map_or(N2::zero(), &abs);
Some(first) => abs(*first),
None => { return N2::zero(); }
};
for e in iter { for e in iter {
let ae = abs(*e); let ae = abs(*e);